public void Value_Returns() { var sut = IncludeExpressionBuilder .CreateBuilder <TestClass>(builder => { builder.AddExpression(a => a.A) .AddExpression(a => a.B) .AddExpression(a => a.C) .AddExpression(a => a.D); }); var array = sut.ToArray(); foreach (var includeExpression in array) { var testClassType = typeof(TestClass); var keyType = includeExpression.GetType().GenericTypeArguments[1]; var genericIncludeExpressionType = typeof(IncludeExpression <,>) .MakeGenericType(testClassType, keyType); var genericFunc = typeof(Func <,>).MakeGenericType(testClassType, typeof(object)); var genericExpression = typeof(Expression <>).MakeGenericType(genericFunc); Assert.IsType(genericIncludeExpressionType, includeExpression); Assert.IsAssignableFrom(genericExpression, includeExpression.Value); } }
public static IQueryable <TModel> IncludeMany <TModel>(this IQueryable <TModel> query, Action <IncludeExpressionBuilder <TModel> > builder) where TModel : class { var includeExpressionBuilder = IncludeExpressionBuilder <TModel> .CreateBuilder(); builder(includeExpressionBuilder); return(IncludeMany(query, includeExpressionBuilder.ToArray())); }