public static Expression <Func <TEntity, bool> > GetFuzzyExpression(FuzzyModel model) { var func = FuzzyQueryHandlerMapping[model.FuzzyField]; if (func != default) { return(func(model)); } else if (PropertiesCache <TEntity> .PropMembers.Contains(model.FuzzyField) && !PropertiesCache <TEntity> .GetBlockWhereFields().Contains(model.FuzzyField)) { var action = NDelegate .DefaultDomain() .Func <FuzzyModel, Expression <Func <TEntity, bool> > >($@" Expression<Func<{typeof(TEntity).GetDevelopName()},bool>> exp = default; if(arg.IgnoreCase) {{ exp = obj => obj.{model.FuzzyField}.Contains(arg.FuzzyValue,StringComparison.CurrentCultureIgnoreCase); }} else {{ exp = obj => obj.{model.FuzzyField}.Contains(arg.FuzzyValue); }} return exp; "); _dict[model.FuzzyField] = action; FuzzyQueryHandlerMapping = _dict.PrecisioTree(); return(action(model)); } return(default);
static HttpContextUpdateOperator() { var stringBuilder = new StringBuilder(); var propNames = typeof(TEntity).GetProperties().Select(item => item.Name); var allowList = PropertiesCache <TEntity> .GetAllowUpdateFields(); stringBuilder.AppendLine($"Expression<Func<{typeof(TEntity).GetDevelopName()},bool>> exp = default;"); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var name in propNames) { if (allowList.Contains(name)) { dict[name] = $"exp = obj => obj.{name} == arg2.{name};"; } } stringBuilder.AppendLine(BTFTemplate.GetGroupPrecisionPointBTFScript(dict, "arg1")); stringBuilder.AppendLine("return exp;"); UpdateFieldsHandler += NDelegate .DefaultDomain() .UnsafeFunc <string, TEntity, Expression <Func <TEntity, bool> > >(stringBuilder.ToString()); }
static QueryOperator() { if (typeof(QueryModel).IsAssignableFrom(typeof(TQueryModel))) { Action <ISelect <TEntity>, TQueryModel> selectAction = (select, queryModel) => { if (queryModel.Orders != null) { var orderBuilder = new StringBuilder(queryModel.Orders.Length * 8); var blockWhereList = PropertiesCache <TEntity> .GetBlockWhereFields(); foreach (var item in queryModel.Orders) { if (!blockWhereList.Contains(item.FieldName) && (PropertiesCache <TEntity> .PropMembers.Contains(item.FieldName) || TableInfomation <TEntity> .PrimaryKey == item.FieldName)) { orderBuilder.Append($"a.\"{item.FieldName}\" "); if (item.IsDesc) { orderBuilder.Append("DESC,"); } else { orderBuilder.Append("ASC,"); } } } if (orderBuilder.Length > 0) { orderBuilder.Length -= 1; select.OrderBy(orderBuilder.ToString()); } } }; SelectWhereHandler += selectAction; } }