Search for existing suggestions

Support tuples in query expressions

With the introduction of first-class support for tuples in C#7, Entity Framework should add support for tuples inside query expressions along.
SO issue here: http://stackoverflow.com/questions/17595105/use-tuples-with-entity-framework-contains-statement

The lack of support for this is super frustrating, especially since anonymous classes are not supported in EF either, and from a performance perspective this is simply a fixed number of values being passed into a query (ie: should not be any more complex to execute on the DB).

For example, the following should work but is currently not supported:

IEnumerable<string> identifers = /*get from somewhere*/....;

Tuple<string, string>[] identifierPairs = originIdentifers.Select( _ => {
string[] compoundIdentifierParts = _.Split( new [] { "::" }, StringSplitOptions.RemoveEmptyEntries );
return Tuple.Create( compoundIdentifierParts[0], compoundIdentifierParts[1] );
}).ToArray();

IEnumerable<Event> matchingItems = await UnitOfWork.ParsedEventRepository.Query()
.Where( _ => identifierPairs.Any( identifier => identifier.Item1 == _.CompoundKeyOne && identifier.Item2 == _.CompoundKeyTwo ))
.Select( _ => _.ProcessedEvent )
.ToListAsync();

3 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Marcel Bradea shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base