using System.Linq.Expressions; namespace ZeroFramework.DeviceCenter.Domain.Specifications.Builder { public static class IncludableBuilderExtensions { public static IIncludableSpecificationBuilder ThenInclude( this IIncludableSpecificationBuilder previousBuilder, Expression> thenIncludeExpression) where TEntity : class { var info = new IncludeExpressionInfo(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(TPreviousProperty)); ((List)previousBuilder.Specification.IncludeExpressions).Add(info); var includeBuilder = new IncludableSpecificationBuilder(previousBuilder.Specification); return includeBuilder; } public static IIncludableSpecificationBuilder ThenInclude( this IIncludableSpecificationBuilder> previousBuilder, Expression> thenIncludeExpression) where TEntity : class { var info = new IncludeExpressionInfo(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(TPreviousProperty)); ((List)previousBuilder.Specification.IncludeExpressions).Add(info); var includeBuilder = new IncludableSpecificationBuilder(previousBuilder.Specification); return includeBuilder; } } }