We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
当一个 ISelect 构造到一定复杂程序之后,比如:
public void Test() { var select1 = fsql.Select<AdmRoute>().Include(a => a.Parent) .WhereIf(!string.IsNullOrEmpty(key), a => a.Name.Contains(key) || a.Extdata.Contains(key) || a.Remark.Contains(key) || a.TenantId.Contains(key) || a.Parent.Name.Contains(key) || a.Parent.Extdata.Contains(key) || a.Parent.Remark.Contains(key) || a.Parent.TenantId.Contains(key)) .WhereIf(Parent_Id?.Any() == true, a => Parent_Id.Contains(a.ParentId)) .WhereIf(mn_Roles_Id?.Any() == true, a => a.Roles.AsSelect().Any(b => mn_Roles_Id.Contains(b.Id))); var select2 = select1; select1.Where(a => a.Status == 0); //此时 select2 也附加了 a.Status == 0 条件 }
利用语法糖解决:
public void Test() { ISelect<AdmRoute> GetSelect() => fsql.Select<AdmRoute>().Include(a => a.Parent) .WhereIf(!string.IsNullOrEmpty(key), a => a.Name.Contains(key) || a.Extdata.Contains(key) || a.Remark.Contains(key) || a.TenantId.Contains(key) || a.Parent.Name.Contains(key) || a.Parent.Extdata.Contains(key) || a.Parent.Remark.Contains(key) || a.Parent.TenantId.Contains(key)) .WhereIf(Parent_Id?.Any() == true, a => Parent_Id.Contains(a.ParentId)) .WhereIf(mn_Roles_Id?.Any() == true, a => a.Roles.AsSelect().Any(b => mn_Roles_Id.Contains(b.Id))); var select1 = GetSelect(); var select2 = GetSelect(); select1.Where(a => a.Status == 0); //此时 select2 不会附加 a.Status == 0 条件 }
科普:
c# 7.0 支持本地函数,方法内再定义临时方法,这个特性向大家推荐,在很多时候都非常有效。
方法内还可以定义方法,那就称它:本地函数/嵌套方法。
The text was updated successfully, but these errors were encountered:
- 优化 导航集合属性访问,可省略 AsSelect;#15 #300 #362 #509 #698 #644 #903
f76a46f
v3.2.600 #1087 #1078 #1066 #903 #698 #644 #509 #362 #300 #15
1f01ea9
v3.2.601 #1087 #1078 #1066 #903 #698 #644 #509 #362 #300 #15
dd8ba93
v3.2.602 #1087 #1078 #1066 #903 #698 #644 #509 #362 #300 #15
b320d08
v3.2.603 #1087 #1078 #1066 #903 #698 #644 #509 #362 #300 #15
10d9090
No branches or pull requests
当一个 ISelect 构造到一定复杂程序之后,比如:
利用语法糖解决:
科普:
c# 7.0 支持本地函数,方法内再定义临时方法,这个特性向大家推荐,在很多时候都非常有效。
方法内还可以定义方法,那就称它:本地函数/嵌套方法。
The text was updated successfully, but these errors were encountered: