protected MethodInfo GetOrderMethod(bool isFirst, QuerySort querySort, Type type, Type[] parameterDefinitions, Type[] chainedOrderParameterDefinitions, Type[] typeArguments) { if (isFirst) { return(querySort.Direction == SortDirection.Ascending ? MethodProvider.MakeGenericMethod(type, "OrderBy", parameterDefinitions, typeArguments) : MethodProvider.MakeGenericMethod(type, "OrderByDescending", parameterDefinitions, typeArguments)); } return(querySort.Direction == SortDirection.Ascending ? MethodProvider.MakeGenericMethod(type, "ThenBy", chainedOrderParameterDefinitions, typeArguments) : MethodProvider.MakeGenericMethod(type, "ThenByDescending", chainedOrderParameterDefinitions, typeArguments)); }
private Expression BuildMasterDetailManyToManyRelationExpression(Expression memberChain, Type masterType, Type detailType, IEnumerable <Type> routeEntityTypes, int currentRouteEntityTypeIndex) { var listProperties = _propertyProvider.GetProperties(detailType).Where(p => p.PropertyType.IsListOfRawGeneric(typeof(Entity <>))); foreach (var detailProperty in listProperties) { var manyToManyType = detailProperty.PropertyType.BaseGenericType().GenericTypeArguments[0]; var masterIdProperty = manyToManyType.GetPropertyIgnoreCase(masterType.Name + "id"); if (masterIdProperty != null) { var unprocessedRouteEntityTypes = GetUnprocessedRouteEntityTypes(routeEntityTypes, currentRouteEntityTypeIndex); unprocessedRouteEntityTypes.Add(manyToManyType); return(Expression.Call( _methodProvider.MakeGenericMethod(typeof(Enumerable), "Any", new Type[] { typeof(IEnumerable <>), typeof(Func <,>) }, new Type[] { manyToManyType }), Expression.Property(memberChain, detailProperty), BuildFilter(unprocessedRouteEntityTypes))); } } return(null); }
public override void Visit(PropertyInfo property, QueryFilterWalkInfo walkInfo) { var member = Expression.Property(walkInfo.Member, property); if (property.PropertyType.IsListOfRawGeneric(typeof(Entity <>))) { var type = property.PropertyType.BaseGenericType().GetGenericArguments()[0]; var whereMethod = _methodProvider.MakeGenericMethod(typeof(Enumerable), "Any", new Type[] { typeof(IEnumerable <>), typeof(Func <,>) }, new Type[] { type }); var parameter = Expression.Parameter(type, type.Name.Camelize()); var lambda = Expression.Lambda(NextWalk(type, walkInfo, parameter), parameter); _expression = Expression.Call(whereMethod, member, lambda); } else if (property.PropertyType.IsSubclassOfRawGeneric(typeof(Entity <>))) { _expression = NextWalk(property.PropertyType, walkInfo, member); } else { _expression = GetPropertyComparisonExpression(member, walkInfo.LogicalFilter); } }
private Expression BuildMasterDetailManyToManyRelationExpression(ParameterExpression parameter, Type masterType, Type detailType, object masterId) { var properties = _propertyProvider.GetProperties(detailType).Where(p => p.PropertyType.IsListOfRawGeneric(typeof(Entity <>))); foreach (var property in properties) { var propertyGenericArgument = property.PropertyType.BaseGenericType().GenericTypeArguments[0]; var masterIdProperty = propertyGenericArgument.GetPropertyIgnoreCase(masterType.Name + "id"); if (masterIdProperty != null) { return(Expression.Call( _methodProvider.MakeGenericMethod(typeof(Enumerable), "Any", new Type[] { typeof(IEnumerable <>), typeof(Func <,>) }, new Type[] { propertyGenericArgument }), Expression.Property(parameter, property), BuildAnyExpresion(propertyGenericArgument, masterIdProperty, masterId))); } } return(null); }