public static IQueryable <TDb> Where <TDb>(this IQueryable <TDb> source, FilterUnitBase filter) { JwtWebApi.Services.Services.Expressions.ParameterExpression parameter = new JwtWebApi.Services.Services.Expressions.ParameterExpression("x", source.ElementType); var search = new Search <TDb>(filter); LambdaExpression selector = new LambdaExpression(search.CreateExpression(parameter.GetExpression()), new IExpression[1] { parameter }); SimpleExpression simpleExpression = new SimpleExpression(source.Expression); return(source.Provider.CreateQuery <TDb>( Expression.Call(typeof(Queryable), "Where", new Type[] { source.ElementType }, source.Expression, selector.GetExpression() ))); }
public DictionaryTypeServiceBase(IDictionaryRowService dictionaryRowService, IDictionaryService dictionaryService) { var className = typeof(T).Name; _dictionaryCode = className.StartsWith("I") ? className.Substring(1) : className; _dictionaryRowService = dictionaryRowService; _dictionaryService = dictionaryService; DictFilter = new BinaryFilterUnit() { Unit2 = new ParameterFilterUnit() { PropertyName = "Code" }, Unit1 = new ConstFilterUnit() { Value = _dictionaryCode }, OperatorType = OperatorType.Equals }; DictRowFilter = new BinaryFilterUnit() { Unit2 = new ParameterFilterUnit() { PropertyName = "DictionaryCode" }, Unit1 = new ConstFilterUnit() { Value = _dictionaryCode }, OperatorType = OperatorType.Equals }; }