mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 23:10:54 +08:00
update
15
多表查询.md
15
多表查询.md
@@ -114,7 +114,7 @@ sql = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
//WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)
|
||||
```
|
||||
|
||||
## 子表 Exists 查询
|
||||
## 子表 Exists
|
||||
```csharp
|
||||
var sql2222 = select.Where(a => select.Where(b => b.Id == a.Id).Any()).ToList();
|
||||
// SELECT a.`Id`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
||||
@@ -141,6 +141,19 @@ sql2222 = select.Where(a =>
|
||||
// limit 0,1))
|
||||
```
|
||||
|
||||
## 子表 First/Count/Sum/Max/Min/Avg
|
||||
```csharp
|
||||
var subquery = select.ToSql(a => new {
|
||||
all = a,
|
||||
first = orm.Select<Child>().Where(b => b.ParentId == a.Id).First(b => b.Id),
|
||||
count = orm.Select<Child>().Where(b => b.ParentId == a.Id).Count(),
|
||||
sum = orm.Select<Child>().Where(b => b.ParentId == a.Id).Sum(b => b.Score),
|
||||
max = orm.Select<Child>().Where(b => b.ParentId == a.Id).Max(b => b.Score),
|
||||
min = orm.Select<Child>().Where(b => b.ParentId == a.Id).Min(b => b.Score),
|
||||
avg = orm.Select<Child>().Where(b => b.ParentId == a.Id).Avg(b => b.Score)
|
||||
});
|
||||
```
|
||||
|
||||
## 参考资料
|
||||
|
||||
- [《利用导航属性查询》](https://github.com/2881099/FreeSql/wiki/%e5%88%a9%e7%94%a8%e5%af%bc%e8%88%aa%e5%b1%9e%e6%80%a7)
|
||||
|
||||
3
更新日志.md
3
更新日志.md
@@ -1,8 +1,9 @@
|
||||
|
||||
完整版本:年数-月-日-当日版本号,FreeSql、FreeSql.Repository、FreeSql.DbContext 版本号相同。
|
||||
|
||||
## v0.7.7
|
||||
## v0.7.8
|
||||
|
||||
- 增加 子查询函数 First、Count、Min、Max、Sum、Avg 的支持 [#wiki](https://github.com/2881099/FreeSql/wiki/%e5%a4%9a%e8%a1%a8%e6%9f%a5%e8%af%a2#%E5%AD%90%E8%A1%A8-exists-%E6%9F%A5%E8%AF%A2);
|
||||
- 补充 Oracle DbFirst raw 等类型映射处理,其他未处理的类型将映射为 string;
|
||||
|
||||
## v0.7.6
|
||||
|
||||
Reference in New Issue
Block a user