update

28810
2019-07-09 16:46:25 +08:00
parent 5c2656b201
commit 312c719a35
2 changed files with 16 additions and 2 deletions

@@ -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)

@@ -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