src/NetStandard/EntityFrameworkCore/Query/src/IQueryableExtensions.cs
/// <summary>
/// This method is very complicated but listen: 
/// <br/><paramref name="keyOneKeyManyEnumerablePairs"/> is going to be flattened down to be compatible with EF Core - a sub query will be made of it.
/// <br/><typeparamref name="OneType"/> must be a part of <typeparamref name="EntityType"/>. <paramref name="getValue"/> is the "pointer" of such part
/// and is used in expression tree for EF Core. Accessing anything other than <typeparamref name="EntityType"/> in scope of <paramref name="getValue"/>
/// is strictly prohibited.
/// <br/><typeparamref name="FlatManyType"/> must be a part of <typeparamref name="EntityType"/>. <paramref name="getFlattenedValue"/> is the "pointer" of such part
/// and is used in expression tree for EF Core. Accessing anything other than <typeparamref name="EntityType"/> in scope of <paramref name="getValue"/>
/// is strictly prohibited.
/// </summary>
/// <typeparam name="EntityType"></typeparam>
/// <typeparam name="OneType"></typeparam>
/// <typeparam name="FlatManyType"></typeparam>
/// <param name="query"></param>
/// <param name="getValue"></param>
/// <param name="getFlattenedValue"></param>
/// <param name="keyOneKeyManyEnumerablePairs"></param>
/// <param name="keyManyEnumerableBehvaiourFlags"></param>
/// <returns></returns>
This method is very complicated but listen:
is going to be flattened down to be compatible with EF Core - a sub query will be made of it.
must be a part of .  is the "pointer" of such part
and is used in expression tree for EF Core. Accessing anything other than  in scope of
is strictly prohibited.
must be a part of .  is the "pointer" of such part
and is used in expression tree for EF Core. Accessing anything other than  in scope of
is strictly prohibited.
This method is very complicated but listen : is going to be flattened down to be compatible with EF Core - a sub query will be made of it . must be a part of . is the " pointer " of such part and is used in expression tree for EF Core . Accessing anything other than in scope of is strictly prohibited . must be a part of . is the " pointer " of such part and is used in expression tree for EF Core . Accessing anything other than in scope of is strictly prohibited .
public static IQueryable<EntityType> HasOneWithMany<EntityType, OneType, FlatManyType>(
            this IQueryable<EntityType> query,
            Expression<Func<EntityType, OneType>> getValue, Expression<Func<EntityType, FlatManyType>> getFlattenedValue,
            IEnumerable<ICovariantKeyValuePair<IYetNullable<OneType>, IEnumerable<FlatManyType>?>>? keyOneKeyManyEnumerablePairs,
            ComparisonItemsBehaviourFlags keyManyEnumerableBehvaiourFlags = ComparisonItemsBehaviourFlags.EmptyLeadsToFalse)
            where OneType : notnull
        {
            if (keyOneKeyManyEnumerablePairs is null) {
                return query;
            }
            var whereExpression = CollectionConstantPredicateBuilder<IMappableCompositeOneToManyKey<OneType, FlatManyType>>
                .CreateFromCollection(keyOneKeyManyEnumerablePairs!)
                .DefinePredicatePerItem(Expression.OrElse,
                    (source, comparisonValue) => comparisonValue.Key.IsNull || Equals(comparisonValue.Key.Value, source.KeyOne))
                .ThenCreateFromCollection(Expression.AndAlso, x => x.Value,
                        comparisonItemsBehaviourFlags: keyManyEnumerableBehvaiourFlags)
                .ThenDefinePredicatePerItem(Expression.OrElse,
                    (source, value) => Equals(source.KeyMany, value))
                .BuildLambdaExpression<EntityType>(mapper => {
                    mapper.MapBodyAndParams(compositeKey => compositeKey.KeyOne, getValue);
                    mapper.MapBodyAndParams(compositeKey => compositeKey.KeyMany, getFlattenedValue);
                });
            return query.Where(whereExpression);
        }
public static IQueryable < EntityType > HasOneWithMany < EntityType , OneType , FlatManyType > ( this IQueryable < EntityType > query , Expression < Func < EntityType , OneType > > getValue , Expression < Func < EntityType , FlatManyType > > getFlattenedValue , IEnumerable < ICovariantKeyValuePair < IYetNullable < OneType > , IEnumerable < FlatManyType > ? > > ? keyOneKeyManyEnumerablePairs , ComparisonItemsBehaviourFlags keyManyEnumerableBehvaiourFlags = ComparisonItemsBehaviourFlags . EmptyLeadsToFalse ) where OneType : notnull { if ( keyOneKeyManyEnumerablePairs is null ) { return query ; } var whereExpression = CollectionConstantPredicateBuilder < IMappableCompositeOneToManyKey < OneType , FlatManyType > > . CreateFromCollection ( keyOneKeyManyEnumerablePairs ! ) . DefinePredicatePerItem ( Expression . OrElse , ( source , comparisonValue ) => comparisonValue . Key . IsNull || Equals ( comparisonValue . Key . Value , source . KeyOne ) ) . ThenCreateFromCollection ( Expression . AndAlso , x => x . Value , comparisonItemsBehaviourFlags : keyManyEnumerableBehvaiourFlags ) . ThenDefinePredicatePerItem ( Expression . OrElse , ( source , value ) => Equals ( source . KeyMany , value ) ) . BuildLambdaExpression < EntityType > ( mapper => { mapper . MapBodyAndParams ( compositeKey => compositeKey . KeyOne , getValue ) ; mapper . MapBodyAndParams ( compositeKey => compositeKey . KeyMany , getFlattenedValue ) ; } ) ; return query . Where ( whereExpression ) ; }
This method is very complicated but listen:
is going to be flattened down to be compatible with EF Core - a sub query will be made of it.
This method is very complicated but listen : is going to be flattened down to be compatible with EF Core - a sub query will be made of it .
None
IQueryable<EntityType>
this
getValue
Expression<Func<EntityType, OneType>>
None
getFlattenedValue
Expression<Func<EntityType, FlatManyType>>
None
keyOneKeyManyEnumerablePairs
IEnumerable<ICovariantKeyValuePair<IYetNullable<OneType>, IEnumerable<FlatManyType>?>>?
None
keyManyEnumerableBehvaiourFlags
ComparisonItemsBehaviourFlags
None
query
None
typeparam
None
typeparam
None
typeparam
None