From 5399ad3527380f9bb374c90237af6b18d5e800d2 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 17 Sep 2022 14:43:56 +0800 Subject: [PATCH] Add unit test --- .../SqlServerTest/UnitTest/UCustom024.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom024.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom024.cs index 9620dca20..9e723fbcc 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom024.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom024.cs @@ -21,7 +21,33 @@ namespace OrmTest db.Queryable().Where(z => z.Id != p.Id).ToList(); var p2 = new Order(); db.Queryable().Where(z => z.Id != p2.Id).ToList(); + db.CurrentConnectionConfig.ConfigureExternalServices = new SqlSugar.ConfigureExternalServices() + { + SqlFuncServices=new List() + { + new SqlSugar.SqlFuncExternal() + { + UniqueMethodName = "MyToString", + MethodValue = (expInfo, dbType, expContext) => + { + return "1"; + } + } + } + }; + var sql2= db.Queryable() + .Select(it => new + { + name= MyToString() + }).ToSql(); + + if (sql2.Key != "SELECT 1 AS name FROM [Order] ") + { + throw new Exception("unit error"); + } } + + public static object MyToString() { return null; } }