You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varres=awaitDb.Value.Select<MemberCoiHistoryModel>().Where(x =>x.Date>=start&&x.Date<end&&x.Type==CoiType.New&&x.State==CoiState.平稳).GroupBy(x =>x.MemberId).WithTempQuery(x =>new{MemberId=x.Key,ScanSum=Db.Value.Select<MemberActionDayCountModel>().As("bbb").Where(y =>y.MemberId==x.Key&&y.Date>=start&&y.Date<end).Sum(y =>y.ScanCode),}).ToAggregateAsync(x =>new{MemberCount=x.Count(),});生成的sql如下:
SELECTCOUNT(1) as1
FROM
(SELECTa.[MemberId],isnull((SELECTSUM(y.[ScanCode])FROM[scrm_member_action_day_count]yWITH(NoLock)
WHERE
(y.[MemberId]=a.[MemberId]AND y.[Date]>=20240101 AND y.[Date]<20240110)),0)[ScanSum]
FROM
[scrm_member_coi_history] a WITH (NoLock)
WHERE
(a.[Date]>=20240101 AND a.[Date]<20240110 AND a.[Type]=1 AND a.[State]=1)
GROUP BY
a.[MemberId]) a
数据库版本
FreeSql.Provider.SqlServer
安装的Nuget包
FreeSql.Provider.SqlServer 3.5.104
.net framework/. net core? 及具体版本
.net 8
The text was updated successfully, but these errors were encountered:
问题描述及重现代码:
1、子Select中使用.As("bbb")时生成的sql中不起使用。
2、因为在顶级Select中默认会使用abc...的别名,而此时如果子Select.Where(a=>...)或是在外边定义的Select中使用a起手的话,最终生成的sql就出问题了,如何能够避免在程序这样的问题发生?
数据库版本
FreeSql.Provider.SqlServer
安装的Nuget包
FreeSql.Provider.SqlServer 3.5.104
.net framework/. net core? 及具体版本
.net 8
The text was updated successfully, but these errors were encountered: