DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.24k stars 1.33k forks source link

SqlFunc.IIF生成的case when then else 语句 else 参数传null 传不了 #1145

Closed dadazxy closed 1 year ago

dadazxy commented 1 year ago

想要这样的语句 SELECT "accountuuid" AS "accountuuid" , "authid" AS "postid" , COUNT(( CASE WHEN ( "abnormaltype" =2 ) THEN 1 ELSE NULL END )) AS "listingabnormalcount" , FROM "t_test" GROUP BY "accountuuid","authid"

生成的是

SELECT "accountuuid" AS "accountuuid" , "authid" AS "postid" , COUNT(( CASE WHEN ( "abnormaltype" = @Abnormaltype0 ) THEN "asin" ELSE @MethodConst1 END )) AS "listingabnormalcount" FROM "t_summaryabnormal" GROUP BY "accountuuid","authid" @Abnormaltype0:2,@MethodConst1:

@MethodConst1传不了null

DotNetNext commented 1 year ago

SqlFunc.MappingColumn(default(string), "null")

可以通过MappingColumn非参数化处理

DotNetNext commented 1 year ago

//最新版本对不参数化进行了语法化 ,还有疑问发新的贴子

SqlFunc.MappingColumn<int>("null")