diff --git a/Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs index 3a74eab08..d87b64697 100644 --- a/Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs @@ -132,7 +132,8 @@ namespace OrmTest datetime=it.CreateTime }) .ToList(); - + var list3 = db.Queryable().Where(it => it.CreateTime.Date == SqlFunc.Oracle_ToDate("2021-1-21", "yyyy-MM-dd")).ToList(); + var list4 = db.Queryable().Select(it => SqlFunc.Oracle_ToChar(DateTime.Now, "yyyy-MM-dd")).ToList(); Console.WriteLine("#### SqlFunc End ####"); } diff --git a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs index 424b4e2ee..aa3ac8aee 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs @@ -130,6 +130,8 @@ namespace OrmTest .Any() ).ToList(); + var list3=db.Queryable().Select(it => SqlFunc.SqlServer_DateDiff("day", DateTime.Now.AddDays(-1), DateTime.Now)).ToList(); + Console.WriteLine("#### Subquery End ####"); } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs index d79102cb5..3c5872439 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -140,8 +140,8 @@ namespace SqlSugar public static int CharIndex(string findChar,string searchValue) { throw new NotSupportedException("Can only be used in expressions"); } public static int BitwiseAnd(int left, int right) { throw new NotSupportedException("Can only be used in expressions"); } public static int BitwiseInclusiveOR(int left, int right) { throw new NotSupportedException("Can only be used in expressions"); } - public static DateTime Oracle_ToDate(object date,string format) { throw new NotSupportedException("Can only be used in expressions"); } - public static string Oracle_ToChar(object date, string format) { throw new NotSupportedException("Can only be used in expressions"); } + public static DateTime Oracle_ToDate(string date,string format) { throw new NotSupportedException("Can only be used in expressions"); } + public static string Oracle_ToChar(DateTime date, string format) { throw new NotSupportedException("Can only be used in expressions"); } public static int SqlServer_DateDiff(string dateType,DateTime date1,DateTime date2) { throw new NotSupportedException("Can only be used in expressions"); } } }