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:

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] );

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

3 votes
Sign in
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 →


Sign in
Sign in with: Facebook Google
Signed in as (Sign out)

Feedback and Knowledge Base