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

IEnumerable.GetEnumerator 是否有实现计划 #948

Closed
wizcabbit opened this issue Dec 1, 2021 · 5 comments
Closed

IEnumerable.GetEnumerator 是否有实现计划 #948

wizcabbit opened this issue Dec 1, 2021 · 5 comments

Comments

@wizcabbit
Copy link
Contributor

Feature 特性

Extensions/FreeSql.Extensions.Linq/QueryableProvider.cs 中
IEnumerable.GetEnumerator 尚未实现,使得IEnumerable接口的实现实际不可用

简要描述原因

IEnumerable接口的实现实际不可用

使用场景

在ASP.NET等场景中,试图用FreeSql替换EntityFramework会需要用到这类接口的实现

@hd2y
Copy link
Contributor

hd2y commented Dec 2, 2021

近期也在尝试这个,发现 ISelect 设计上的问题,有些进行不下去。用起来会和正常的 IQueryable 有些区别。

例如:

IFreeSql freeSql = new FreeSqlBuilder()
    .UseConnectionString(DataType.Sqlite, "Data Source=:memory:;")
    .UseAutoSyncStructure(true)
    .Build();

freeSql.Aop.CurdBefore += (s, e) =>
{
    e.Sql.Dump();
};

var sel = freeSql.Select<Student>();

sel.Where(t=>t.Id == 1).ToList();
sel.Where(t=>t.Id == 2).ToList();

期望结果:

-- sel.Where(t=>t.Id == 1).ToList();
SELECT a."Id", a."Name"
FROM "Student" a
WHERE (a."Id" = 1)

-- sel.Where(t=>t.Id == 2).ToList();
SELECT a."Id", a."Name"
FROM "Student" a
WHERE (a."Id" = 2)

实际:

-- sel.Where(t=>t.Id == 1).ToList();
SELECT a."Id", a."Name"
FROM "Student" a
WHERE (a."Id" = 1)

-- sel.Where(t=>t.Id == 2).ToList();
SELECT a."Id", a."Name"
FROM "Student" a
WHERE (a."Id" = 1) AND (a."Id" = 2)

hd2y/MySamples@77b8c70

@luoyunchong
Copy link
Collaborator

@hd2y
#644

@hd2y
Copy link
Contributor

hd2y commented Dec 2, 2021

@hd2y #644

和这个例子没有关系的,追求的不是这个效果。因为 AsQueryable 依赖于 ISelect,所以看起来是支持 IQueryable 的功能,但是实际执行的结果是完全不一样的,一旦应用在项目中,会给团队里其他用 EF 的小伙伴造成困扰。

@luoyunchong
Copy link
Collaborator

Where会修改前面的值。

@hd2y
Copy link
Contributor

hd2y commented Dec 2, 2021

Where会修改前面的值。

是的,我是在研究如何用 System.Linq.Dynamic.Core,但是因为这个问题暂时也搁置了。

#782

@2881099 2881099 closed this as completed Nov 8, 2022
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

4 participants