update

28810
2020-06-27 04:13:25 +08:00
parent 311479e04f
commit 9fd2e09faa
3 changed files with 14 additions and 10 deletions

1
API.md

@@ -41,6 +41,7 @@
| [GetRepository](https://github.com/2881099/FreeSql/wiki/Repository)\<TEntity, TKey\> | BaseRepository | 无 | 返回默认仓库功能实现 |
| [CreateUnitOfWork](https://github.com/2881099/FreeSql/wiki/%e5%b7%a5%e4%bd%9c%e5%8d%95%e5%85%83) | IUnitOfWork | 无 | 创建基于仓储功能的工作单元,务必使用 using 包含使用 |
| ToTreeList() | List\<TEntity\> | 无 | 将父子关系的数据以 TreeList 的形式返回 |
| AsCteTree() | ISelect | 无 | 递归查询父子关系的所有子记录 |
---

@@ -5,7 +5,8 @@
- **增加 人大金仓 OdbcKingbaseES 实现;#325**
- **增加 神州通用 ShenTong 实现;**
- **增加 WhereDynamicFilter 操作符 Range/DateRange/Any/NotAny实现范围/日期范围/In查询**
- **增加 WhereDynamicFilter 操作符 Range/DateRange/Any/NotAny实现范围/日期范围/In查询**
- **增加 ISelect.AsCteTree() 递归查询树表所有子记录;**
- 增加 IUnitOfWork Orm 属性直接访问 IFreeSql CRUD 事务与工作单元一致;
- 增加 SqlExt 常用开窗函数的自定义表达式解析;
- 增加 SqlExt.Case().When(..).End() 自定义表达式解析;

@@ -15,28 +15,30 @@ List<Topic> t1 = fsql.Select<Topic>().ToList();
## 3、返回 TreeList
```csharp
List<Category> t2 = fsql.Select<Category>.ToTreeList();
List<Category> t3 = fsql.Select<Category>.Where(a => a.Name = "家电").AsCteTree().ToTreeList();
//v1.6.0 AsCteTree() 递归CTE查询 家电 下的所有子分类
```
查询数据加工为树型,注意:实体需要配置父子导航属性
## 4、返回 List + 导航属性的数据
```csharp
List<Topic> t3 = fsql.Select<Topic>().LeftJoin(a => a.Type.Id == a.TypeId).ToList();
List<Topic> t4 = fsql.Select<Topic>().LeftJoin(a => a.Type.Id == a.TypeId).ToList();
//此时会返回普通字段 + 导航对象 Type 的数据
```
## 5、指定字段返回
```csharp
//返回一个字段
List<int> t4 = fsql.Select<Topic>().ToList(a => a.Id);
List<int> t5 = fsql.Select<Topic>().ToList(a => a.Id);
//返回匿名类
List<匿名类> t5 = fsql.Select<Topic>().ToList(a => new { a.Id, a.Title });
List<匿名类> t6 = fsql.Select<Topic>().ToList(a => new { a.Id, a.Title });
//返回元组
List<(int, string)> t6 = fsql.Select<Topic>().ToList<(int, string)>("id, title");
List<(int, string)> t7 = fsql.Select<Topic>().ToList<(int, string)>("id, title");
//返回SQL字段
List<匿名类> t7 = fsql.Select<Topic>().ToList(a => new {
List<匿名类> t8 = fsql.Select<Topic>().ToList(a => new {
a.Id,
a.Title,
a.Type, //可以直接返回导航属性 Type
@@ -46,7 +48,7 @@ List<匿名类> t7 = fsql.Select<Topic>().ToList(a => new {
});
//返回子查询的字段
List<匿名类> t8 = fsql.Select<Topic>().ToList(a => new {
List<匿名类> t9 = fsql.Select<Topic>().ToList(a => new {
a.Id,
count = fsql.Select<T2>().Count(),
max = fsql.Select<T2>().Max(b => b.Id),
@@ -70,9 +72,9 @@ class xxx {
public string Title2 { get; set; }
}
List<xxx> t9 = fsql.Ado.Query<xxx>("select * from song");
List<(int, string ,string)> t10 = fsql.Ado.Query<(int, string, string)>("select * from song");
List<dynamic> t11 = fsql.Ado.Query<dynamic>("select * from song");
List<xxx> t10 = fsql.Ado.Query<xxx>("select * from song");
List<(int, string ,string)> t11 = fsql.Ado.Query<(int, string, string)>("select * from song");
List<dynamic> t12 = fsql.Ado.Query<dynamic>("select * from song");
```
> 注意Ado.Query 的实体特性是无效的,比如 [Column(Name = "xxx")] 无效