mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-26 10:10:56 +08:00
update
19
返回数据.md
19
返回数据.md
@@ -37,18 +37,21 @@ List<匿名类> t6 = fsql.Select<Topic>().ToList(a => new { a.Id, a.Title });
|
|||||||
//返回元组
|
//返回元组
|
||||||
List<(int, string)> t7 = fsql.Select<Topic>().ToList<(int, string)>("id, title");
|
List<(int, string)> t7 = fsql.Select<Topic>().ToList<(int, string)>("id, title");
|
||||||
|
|
||||||
//返回SQL字段
|
//返回导航属性
|
||||||
List<匿名类> t8 = fsql.Select<Topic>().ToList(a => new {
|
List<匿名类> t8 = fsql.Select<Topic>().ToList(a => new {
|
||||||
a.Id,
|
a.Id, a.Title,
|
||||||
a.Title,
|
a.Type //可以直接返回导航属性 Type
|
||||||
a.Type, //可以直接返回导航属性 Type
|
});
|
||||||
|
|
||||||
|
//返回SQL字段
|
||||||
|
List<匿名类> t9 = fsql.Select<Topic>().ToList(a => new {
|
||||||
cstitle = "substr(a.title, 0, 2)", //将 substr(a.title, 0, 2) 作为查询字段
|
cstitle = "substr(a.title, 0, 2)", //将 substr(a.title, 0, 2) 作为查询字段
|
||||||
csnow = Convert.ToDateTime("now()"), //将 now() 作为查询字段
|
csnow = Convert.ToDateTime("now()"), //将 now() 作为查询字段
|
||||||
//奇思妙想:怎么查询开窗函数的结果
|
//奇思妙想:怎么查询开窗函数的结果
|
||||||
});
|
});
|
||||||
|
|
||||||
//返回子查询的字段
|
//返回子查询的字段
|
||||||
List<匿名类> t9 = fsql.Select<Topic>().ToList(a => new {
|
List<匿名类> t10 = fsql.Select<Topic>().ToList(a => new {
|
||||||
a.Id,
|
a.Id,
|
||||||
count = fsql.Select<T2>().Count(),
|
count = fsql.Select<T2>().Count(),
|
||||||
max = fsql.Select<T2>().Max(b => b.Id),
|
max = fsql.Select<T2>().Max(b => b.Id),
|
||||||
@@ -74,9 +77,9 @@ class xxx {
|
|||||||
public string Title2 { get; set; }
|
public string Title2 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
List<xxx> t10 = fsql.Ado.Query<xxx>("select * from song");
|
List<xxx> t11 = fsql.Ado.Query<xxx>("select * from song");
|
||||||
List<(int, string ,string)> t11 = fsql.Ado.Query<(int, string, string)>("select * from song");
|
List<(int, string ,string)> t12 = fsql.Ado.Query<(int, string, string)>("select * from song");
|
||||||
List<dynamic> t12 = fsql.Ado.Query<dynamic>("select * from song");
|
List<dynamic> t13 = fsql.Ado.Query<dynamic>("select * from song");
|
||||||
```
|
```
|
||||||
|
|
||||||
> 注意:Ado.Query 的实体特性是无效的,比如 [Column(Name = "xxx")] 无效
|
> 注意:Ado.Query 的实体特性是无效的,比如 [Column(Name = "xxx")] 无效
|
||||||
|
|||||||
Reference in New Issue
Block a user