mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-18 06:10:56 +08:00
Updated Return Data (markdown)
@@ -75,18 +75,18 @@ List<ANONYMOUS_TYPE> t10 = fsql.Select<Topic>().ToList(a => new {
|
||||
|
||||
> In the early constant mechanism, we left it to raw SQL. If you really need to return the string, you can write: "'xxx'"
|
||||
|
||||
### Ignore the Specified Field When Returning
|
||||
## Ignore the Specified Field When Returning
|
||||
|
||||
Reference to: https://github.com/dotnetcore/FreeSql/issues/528
|
||||
|
||||
### ToSql
|
||||
## ToSql
|
||||
|
||||
All `ToList` can use `ToSql` to return SQL string. There are two options:
|
||||
|
||||
- FieldAliasOptions.AsIndex(默认) 自动产生 as1, as2, as3 .... 字段别名,可以最大程度防止多表,存在相同字段的问题;
|
||||
- FieldAliasOptions.AsProperty 使用属性名作为字段别名,合适使用二次构造 SQL 再次执行;
|
||||
- FieldAliasOptions.AsIndex, the default option, automatically generates as1, as2, as3 .... etc. field aliases, which can prevent the problem of multiple tables with the same field.
|
||||
- FieldAliasOptions.AsProperty, use the property name as the field alias, appropriately use the two-stage structure SQL and execute it again.
|
||||
|
||||
### Executing SQL
|
||||
## Executing SQL
|
||||
|
||||
```csharp
|
||||
class xxx {
|
||||
@@ -134,16 +134,16 @@ fsql.Select<Song>().OrderBy(a => a.Id).ToChunk(100, done => {
|
||||
|
||||
```csharp
|
||||
fsql.Select<Song>().ToList<Dto>();
|
||||
//情况1:Dto 与 Song 属性名相同的字段被查询,返回 List<Dto>
|
||||
//Case 1: The field with the same property name of Dto and Song is queried, and List<Dto> is returned
|
||||
|
||||
fsql.Select<Song>().ToList(a => new Dto { xxx = a.ext })
|
||||
//情况2:Dto 与 Song 属性名相同的字段被查询,纠正映射 ext,返回 List<Dto>
|
||||
//Case 2: The field with the same property name of Dto and Song is queried, the mapping ext is adjusted, and List<Dto> is returned
|
||||
|
||||
fsql.Select<Song>().ToList(a => new Song { id = a.id })
|
||||
//情况3:Lambda 与 Song 类型一样,只查询指定字段 id,返回 List<Song>
|
||||
//Case 3: The type specified by Lambda is the same as the type of Song, only the specified field id is queried, and List<Song> is returned
|
||||
|
||||
fsql.Select<Song>().ToList(a => new { id = a.id })
|
||||
//情况4:Lambda 匿名类型,只查询指定字段 id,返回 List<匿名对象>
|
||||
//Case 4: Lambda specifies an anonymous type, only queries the specified field id, and returns List<ANONYMOUS_OBJECT>
|
||||
```
|
||||
|
||||
> Please handle the difference carefully.
|
||||
|
||||
Reference in New Issue
Block a user