Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseEntity模式下使用 子表First/Count/Sum/Max/Min/Avg 出错 #1586

Closed
j4587698 opened this issue Aug 9, 2023 · 3 comments
Closed

BaseEntity模式下使用 子表First/Count/Sum/Max/Min/Avg 出错 #1586

j4587698 opened this issue Aug 9, 2023 · 3 comments

Comments

@j4587698
Copy link

j4587698 commented Aug 9, 2023

问题描述及重现代码:

假设有类A继承于BaseEntity,类B继承于BaseEntity
使用代码

await A.Select.ToListAsync(x => new 
        {
            Count = B.Where(y => y.AId == x.Id).Count()
        });

报错

System.AggregateException: One or more errors occurred. (variable 'x' of type 'A' referenced from scope '', but it is not defined)

如果改用

freeSql.Select<B>().Where(y => y.AId == x.Id).Count()

则正常

数据库版本

sqlite

安装的Nuget包

3.2.70-preview20230726

.net framework/. net core? 及具体版本

.net7

@2881099
Copy link
Collaborator

2881099 commented Aug 10, 2023

Count = B.Select.Where(y => y.AId == x.Id).Count()

@2881099
Copy link
Collaborator

2881099 commented Aug 10, 2023

see #216

@2881099
Copy link
Collaborator

2881099 commented Aug 10, 2023

已优化等待下次发布版本

当前可以使用 Count = B.Select.Where(y => y.AId == x.Id).Count() 解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants