mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 23:10:54 +08:00
update
27
多表查询.md
27
多表查询.md
@@ -126,29 +126,22 @@ sql = fsql.Select<Topic, TestTypeInfo, TestTypeParentInfo>()
|
|||||||
|
|
||||||
## 子表 Exists
|
## 子表 Exists
|
||||||
```csharp
|
```csharp
|
||||||
var sql2222 = select.Where(a => select.Where(b => b.Id == a.Id).Any()).ToList();
|
var list2 = select.Where(a => select.Where(b => b.Id == a.Id).Any()).ToList();
|
||||||
// SELECT a.`Id`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
// SELECT a.`Id`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
||||||
// FROM `xxx` a
|
// FROM `xxx` a
|
||||||
// WHERE (exists(SELECT 1
|
// WHERE (exists(SELECT 1
|
||||||
// FROM `xxx` b
|
// FROM `xxx` b
|
||||||
// WHERE (b.`Id` = a.`Id`)))
|
// WHERE (b.`Id` = a.`Id`)))
|
||||||
|
```
|
||||||
|
|
||||||
//两级相同的子表查询
|
## 子表 In
|
||||||
sql2222 = select.Where(a =>
|
|
||||||
select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id)
|
```csharp
|
||||||
.Offset(a.Id)
|
var list2 = select.Where(a => select.ToList(b => b.Id).Contains(a.Id)).ToList();
|
||||||
.Any()
|
// SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
||||||
).Any()
|
// FROM `tb_topic` a
|
||||||
).ToList();
|
// WHERE (((cast(a.`Id` as char)) in (SELECT b.`Title`
|
||||||
// SELECT a.`Id`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
// FROM `tb_topic` b)))
|
||||||
// FROM `xxx` a
|
|
||||||
// WHERE (exists(SELECT 1
|
|
||||||
// FROM `xxx` b
|
|
||||||
// WHERE (b.`Id` = a.`Id` AND exists(SELECT 1
|
|
||||||
// FROM `xxx` c
|
|
||||||
// WHERE (c.`Id` = b.`Id`) AND (c.`Id` = a.`Id`) AND (c.`Id` = b.`Id`)
|
|
||||||
// limit 0,1))
|
|
||||||
// limit 0,1))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 子表 First/Count/Sum/Max/Min/Avg
|
## 子表 First/Count/Sum/Max/Min/Avg
|
||||||
|
|||||||
3
更新日志.md
3
更新日志.md
@@ -3,8 +3,11 @@
|
|||||||
|
|
||||||
## v1.0.0(预告)
|
## v1.0.0(预告)
|
||||||
|
|
||||||
|
- 增加 Where In 表达式解析;[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)
|
||||||
|
- 增加 FreeSqlBuilder.UseConnectionFactory 自定义数据库连接对象的创建方法;
|
||||||
- 兼容 Vb.Net 表达式解析字符串 = 判断;
|
- 兼容 Vb.Net 表达式解析字符串 = 判断;
|
||||||
- 优化 GlobalFilter 过滤器表达式 bool 解析;
|
- 优化 GlobalFilter 过滤器表达式 bool 解析;
|
||||||
|
- 修复 ISelect.AsTable union all 查询对 count/max/min/avg/sum 的别名 bug;
|
||||||
|
|
||||||
## v0.12.20
|
## v0.12.20
|
||||||
|
|
||||||
|
|||||||
20
表达式函数.md
20
表达式函数.md
@@ -34,6 +34,26 @@ var t2 = fsql.Select<T>()
|
|||||||
//a."Id" = 'b8b366f3-1c03-4547-9c96-d362dd5cae6a' AND a."ct1" = '2019-12-07 23:55:27')
|
//a."Id" = 'b8b366f3-1c03-4547-9c96-d362dd5cae6a' AND a."ct1" = '2019-12-07 23:55:27')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 子表 In
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var list2 = select.Where(a => select.ToList(b => b.Id).Contains(a.Id)).ToList();
|
||||||
|
// SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
||||||
|
// FROM `tb_topic` a
|
||||||
|
// WHERE (((cast(a.`Id` as char)) in (SELECT b.`Title`
|
||||||
|
// FROM `tb_topic` b)))
|
||||||
|
```
|
||||||
|
|
||||||
|
## 子表 Exists
|
||||||
|
```csharp
|
||||||
|
var list2 = select.Where(a => select.Where(b => b.Id == a.Id).Any()).ToList();
|
||||||
|
// SELECT a.`Id`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
||||||
|
// FROM `xxx` a
|
||||||
|
// WHERE (exists(SELECT 1
|
||||||
|
// FROM `xxx` b
|
||||||
|
// WHERE (b.`Id` = a.`Id`)))
|
||||||
|
```
|
||||||
|
|
||||||
## 查找今天创建的数据
|
## 查找今天创建的数据
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
|||||||
Reference in New Issue
Block a user