public static IIncludableSpecificationBuilder <T, TProperty> Include <T, TProperty>( this ISpecificationBuilder <T> specificationBuilder, Expression <Func <T, TProperty> > includeExpression) { var aggregator = new IncludeAggregator((includeExpression.Body as MemberExpression)?.Member?.Name); var includeBuilder = new IncludableSpecificationBuilder <T, TProperty>(specificationBuilder.Specification, aggregator); ((List <IIncludeAggregator>)specificationBuilder.Specification.IncludeAggregators).Add(aggregator); return(includeBuilder); }
public static IIncludableSpecificationBuilder <T, TProperty> Include <T, TProperty>( this ISpecificationBuilder <T> specificationBuilder, Expression <Func <T, TProperty> > includeExpression) where T : class { var info = new IncludeExpressionInfo(includeExpression, typeof(T), typeof(TProperty)); ((List <IncludeExpressionInfo>)specificationBuilder.Specification.IncludeExpressions).Add(info); var includeBuilder = new IncludableSpecificationBuilder <T, TProperty>(specificationBuilder.Specification); return(includeBuilder); }
public static IIncludableSpecificationBuilder <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>( this IIncludableSpecificationBuilder <TEntity, TPreviousProperty> previousBuilder, Expression <Func <TPreviousProperty, TProperty> > thenIncludeExpression) where TEntity : class { var info = new IncludeExpressionInfo(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(TPreviousProperty)); ((List <IncludeExpressionInfo>)previousBuilder.Specification.IncludeExpressions).Add(info); var includeBuilder = new IncludableSpecificationBuilder <TEntity, TProperty>(previousBuilder.Specification); return(includeBuilder); }
public static IIncludableSpecificationBuilder <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>( this IIncludableSpecificationBuilder <TEntity, IEnumerable <TPreviousProperty> > previousBuilder, Expression <Func <TPreviousProperty, TProperty> > thenIncludeExpression, bool condition) where TEntity : class { if (condition && !previousBuilder.IsChainDiscarded) { var info = new IncludeExpressionInfo(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(IEnumerable <TPreviousProperty>)); ((List <IncludeExpressionInfo>)previousBuilder.Specification.IncludeExpressions).Add(info); } var includeBuilder = new IncludableSpecificationBuilder <TEntity, TProperty>(previousBuilder.Specification, !condition || previousBuilder.IsChainDiscarded); return(includeBuilder); }