select时,SqlFunc.IIF不能用来判断是否子查询或返回null吗 返回
SqlSugar
处理完成
3
195
发布于1个月前
悬赏:0 飞吻
lessonEntryRecord字段是一个实体类型,直接子查询没有问题
.Select(p => new LessonInfoDto() { Id = p.Id, lessonEntryRecord = SqlFunc.IIF(memberType > 0, SqlFunc.Subqueryable<LessonEntryRecord>().Where(c => c.LessonId == p.Id && c.MemberId == param.MemberId.Value && c.EntryState == (int)LessonEntryEnum.EntryStateEnum.BMCG && c.RefundState == (int)LessonEntryEnum.ReturnStateEnum.WTH).First(), null), });
使用SqlFunc.IIF后 ,生成的sql不对
SELECT [Id] AS [Id] , [MemberId] AS [LessonEntryRecord.MemberId] , [LessonId] AS [LessonEntryRecord.LessonId] FROM [LessonInfo] [p] WHERE ( [Id] > 0 )
这样会报错 没有MemberId和LessonId字段
热忱回答(3)
-
fate sta VIP01个月前
.First() 这个语法是错的
0 回复 -
fate sta VIP01个月前
.First()方法是返回一个对象,只能单独用
0 回复 -
fate sta VIP01个月前
逻辑写到子查询中
0 回复