diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs index 36a2713a2..e1a4ff00c 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs @@ -5,6 +5,8 @@ using System.Text; using System.Data; using System.Reflection; using System.Reflection.Emit; +using System.Text.RegularExpressions; + namespace SqlSugar { /// @@ -159,6 +161,9 @@ namespace SqlSugar MethodInfo method = null; Type bindPropertyType = PubMethod.GetUnderType(bindProperty, ref isNullableType); string dbTypeName = DataRecord.GetDataTypeName(ordinal); + if (Regex.IsMatch(dbTypeName, @"\(.+\)")) { + dbTypeName = Regex.Replace(dbTypeName,@"\(.+\)", ""); + } string propertyName = bindProperty.Name; string validPropertyName = bind.GetPropertyTypeName(dbTypeName); validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName; diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteExpressionContext.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteExpressionContext.cs index 18a37a342..906e6519a 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteExpressionContext.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteExpressionContext.cs @@ -54,6 +54,26 @@ namespace SqlSugar } public class SqliteMethod : DefaultDbMethod, IDbMethods { - + public override string Contains(MethodCallExpressionModel model) + { + var parameter = model.Args[0]; + var parameter2 = model.Args[1]; + return string.Format(" ({0} like '%'||{1}||'%') ", parameter.MemberName, parameter2.MemberName); + } + + public override string StartsWith(MethodCallExpressionModel model) + { + var parameter = model.Args[0]; + var parameter2 = model.Args[1]; + return string.Format(" ({0} like '%'||{1}) ", parameter.MemberName, parameter2.MemberName); + } + + public override string EndsWith(MethodCallExpressionModel model) + { + var parameter = model.Args[0]; + var parameter2 = model.Args[1]; + return string.Format(" ({0} like {1}||'%') ", parameter.MemberName, parameter2.MemberName); + } + } } diff --git a/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite b/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite index 9e1add14f..0ea8e847d 100644 Binary files a/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite and b/Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite differ diff --git a/Src/Asp.Net/SqliteTest/Program.cs b/Src/Asp.Net/SqliteTest/Program.cs index bc5007cc9..0a110a5f0 100644 --- a/Src/Asp.Net/SqliteTest/Program.cs +++ b/Src/Asp.Net/SqliteTest/Program.cs @@ -17,19 +17,19 @@ namespace OrmTest { static void Main(string[] args) { - ////// /***Unit Test***/ - //new Field(1).Init(); - //new Where(1).Init(); - //new Method(1).Init(); - //new JoinQuery(1).Init(); - //new SingleQuery(1).Init(); - //new SelectQuery(1).Init(); - //new AutoClose(1).Init(); - //new Insert(1).Init(); - //new Delete(1).Init(); - //new Update(1).Init(); - //new Mapping(1).Init(); - //new DataTest(1).Init(); + /***Unit Test***/ + new Field(1).Init(); + new Where(1).Init(); + new Method(1).Init(); + new JoinQuery(1).Init(); + new SingleQuery(1).Init(); + new SelectQuery(1).Init(); + new AutoClose(1).Init(); + new Insert(1).Init(); + new Delete(1).Init(); + new Update(1).Init(); + new Mapping(1).Init(); + new DataTest(1).Init(); //// /***Performance Test***/ //// new SqlSugarPerformance(100).Select(); diff --git a/Src/Asp.Net/SqliteTest/UnitTest/Query/SingleQuery.cs b/Src/Asp.Net/SqliteTest/UnitTest/Query/SingleQuery.cs index 4d0067e0a..1189fdfb1 100644 --- a/Src/Asp.Net/SqliteTest/UnitTest/Query/SingleQuery.cs +++ b/Src/Asp.Net/SqliteTest/UnitTest/Query/SingleQuery.cs @@ -95,7 +95,7 @@ namespace OrmTest.UnitTest .Where(it=>it.Id==1) .WhereIF(true,it=> SqlFunc.Contains(it.Name,"a")) .OrderBy(it => it.Id, OrderByType.Desc).Skip((pageIndex - 1) * pageSize).Take(pageSize ).With(SqlWith.NoLock).ToSql(); - base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` WHERE ( `ID` = @Id0 ) AND (`Name` like concat('%',@MethodConst1,'%')) ORDER BY `ID` DESC LIMIT 10,10", new List() { + base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` WHERE ( `ID` = @Id0 ) AND (`Name` like '%'||@MethodConst1||'%') ORDER BY `ID` DESC LIMIT 10,10", new List() { new SugarParameter("@Id0",1),new SugarParameter("@MethodConst1","a") }, t8.Key, t8.Value,"single t8 Error"); @@ -104,7 +104,7 @@ namespace OrmTest.UnitTest var t9 = db.Queryable() .In(1) .Select(it => new { it.Id, it.Name,x=it.Id }).ToSql(); - base.Check("SELECT `ID` AS `Id` , `Name` AS `Name` , `ID` AS `x` FROM `STudent` WHERE `ID` IN (@InPara0) ", new List() { + base.Check("SELECT `ID` AS `Id` , `Name` AS `Name` , `ID` AS `x` FROM `STudent` WHERE `Id` IN (@InPara0) ", new List() { new SugarParameter("@InPara0",1) },t9.Key,t9.Value, "single t9 error"); } }