public void AddConditionItem(string field, QueryMethod method, QueryUnite queryUnite, QueryDataType queryDataType, object val) { ConditionItem item = new ConditionItem { Field = field, Method = method, Value = val, QueryUnite = queryUnite, QueryDataType = queryDataType }; this.Items.Add(item); }
public IEnumerable <ConditionItem> Transform(ConditionItem item, Type type) { Array val = item.Value as Array; if (val == null) { string str = item.Value.ToString(); if (!string.IsNullOrEmpty(str)) { val = str.Split(new char[] { ',' }); } } return(new ConditionItem[] { new ConditionItem(item.Field, QueryMethod.StdIn, val) }); }
private Expression GetExpression <T>(ParameterExpression param, ConditionItem item) { LambdaExpression propertyLambdaExpression = this.GetPropertyLambdaExpression <T>(item, param); foreach (ITransformProvider provider in TransformProviders) { if (provider.Match(item, propertyLambdaExpression.Body.Type)) { return(this.GetGroupExpression <T>(param, provider.Transform(item, propertyLambdaExpression.Body.Type), new Func <Expression, Expression, Expression>(Expression.AndAlso))); } } Expression expression2 = ChangeTypeToExpression(item, propertyLambdaExpression.Body.Type); return(ExpressionDict[item.Method](propertyLambdaExpression.Body, expression2)); }
private LambdaExpression GetPropertyLambdaExpression <T>(ConditionItem item, ParameterExpression param) { string[] strArray = item.Field.Split(new char[] { '.' }); Expression expression = param; Type propertyType = typeof(T); int index = 0; do { PropertyInfo property = propertyType.GetProperty(strArray[index]); if (property == null) { return(null); } propertyType = property.PropertyType; expression = Expression.MakeMemberAccess(expression, property); index++; }while (index < strArray.Length); return(Expression.Lambda(expression, new ParameterExpression[] { param })); }
public bool Match(ConditionItem item, Type type) { return(item.Method == QueryMethod.In); }