diff --git a/Src/Asp.Net/SqliteTest/UnitTest/UQueryable.cs b/Src/Asp.Net/SqliteTest/UnitTest/UQueryable.cs index fc96188c2..4df23ef99 100644 --- a/Src/Asp.Net/SqliteTest/UnitTest/UQueryable.cs +++ b/Src/Asp.Net/SqliteTest/UnitTest/UQueryable.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace OrmTest @@ -93,9 +94,32 @@ namespace OrmTest { throw new Exception("unit error"); } + + List conModels = new List(); + conModels.Add(new ConditionalModel() + { + FieldName = "name", + FieldValue = "1", + CustomConditionalFunc= new MyConditional() + }); + conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Like, FieldValue = "1" }); + var list8=Db.Queryable().Where(conModels).ToList(); } - + public class MyConditional : ICustomConditionalFunc + { + public KeyValuePair GetConditionalSql(ConditionalModel conditionalModel,int index) + { + var parameterName= "@myp" + index; + SugarParameter[] pars = new SugarParameter[] + { + new SugarParameter(parameterName, conditionalModel.FieldValue ) + }; + //自已处理字符串安全,也可以使用我自带的 + return new KeyValuePair + ($" { conditionalModel.FieldName.ToCheckRegexW() } = {parameterName}", pars); + } + } public class UnitAbc121 { [SugarColumn(IsNullable =true)]