Merge branch 'SqlSugar5' of github.com:donet5/SqlSugar

This commit is contained in:
sunkaixuan
2022-04-15 19:26:53 +08:00

View File

@@ -31,12 +31,13 @@ Using SqlSugar is very simple , And it's powerful.
| ----- | --------- | ----------- | ------- |------- |
<a href="https://github.com/donet5/SqlSugar/wiki/NUGET">Nuget</a>| [Simple query](https://www.donet5.com/Home/Doc?typeId=1187) | <a href="https://www.donet5.com/Home/Doc?typeId=1193"> Insert </a> |<a href="https://www.donet5.com/Home/Doc?typeId=1191">Update</a>| <a href="https://www.donet5.com/Home/Doc?typeId=1195">Delete</a> |
[Start guide](https://github.com/donet5/SqlSugar/wiki/Create--database-operation-object)| <a target="_bank" href="https://www.donet5.com/Home/Doc?typeId=1185">Join query </a> | | | | |
| | <a href="https://www.donet5.com/Home/Doc?typeId=1188">Include query</a>||||
## Feature characteristic
### Feature1 : Join query
Super simple query syntax
```cs
var query5 = db.Queryable<Order>()
var query = db.Queryable<Order>()
.LeftJoin<Custom> ((o, cus) => o.CustomId == cus.Id)
.LeftJoin<OrderItem> ((o, cus, oritem ) => o.Id == oritem.OrderId)
.LeftJoin<OrderItem> ((o, cus, oritem , oritem2) => o.Id == oritem2.OrderId)
@@ -56,8 +57,15 @@ FROM
WHERE
([o].[Id] = @Id0)
```
### Feature2 : Include query
```cs Include Query
var list=db.Queryable<Test>()
.Includes(x => x.Provinces,x=>x.Citys ,x=>x.Street)
.Includes(x => x.ClassInfo)
.ToList();
```
### Feature2 : Page query
### Feature3 : Page query
```cs
int pageIndex = 1;
@@ -66,7 +74,7 @@ WHERE
var page = db.Queryable<Student>().ToPageList(pageIndex, pageSize, ref totalCount);
```
### Feature3 : Dynamic expression
### Feature4 : Dynamic expression
```cs
var names= new string [] { "a","b"};
Expressionable<Order> exp = new Expressionable<Order>();
@@ -83,7 +91,7 @@ SELECT [Id],[Name],[Price],[CreateTime],[CustomId]
([Name] like '%'+ CAST(@MethodConst1 AS NVARCHAR(MAX))+'%')
)
```
### Feature4 : Multi-tenant transaction
### Feature5 : Multi-tenant transaction
```cs
//Creaate database object
SqlSugarClient db = new SqlSugarClient(new List<ConnectionConfig>()
@@ -109,7 +117,7 @@ db.BeginTran();
db.CommitTran();
```
### Feature5 : Singleton Pattern
### Feature6 : Singleton Pattern
Implement transactions across methods
```CS
public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
@@ -138,7 +146,7 @@ public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
tran.CommitTran();
}
```
### Feature6 : Query filter
### Feature7 : Query filter
```cs
//set filter
db.QueryFilter.Add(new TableFilterItem<Order>(it => it.Name.Contains("a")));
@@ -155,7 +163,7 @@ db.Queryable<OrderItem, Order>((i, o) => i.OrderId == o.Id)
```
### Feature7 : Insert or update
### Feature8 : Insert or update
insert or update
```cs
var x = Db.Storageable(list2).ToStorage();
@@ -168,7 +176,7 @@ var x = Db.Storageable(list).SplitInsert(it => !it.Any()).ToStorage()
x.AsInsertable.ExecuteCommand();
```
### Feature8 Auto split table
### Feature9 Auto split table
Split entity
```cs
[SplitTable(SplitType.Year)]//Table by year (the table supports year, quarter, month, week and day)
@@ -194,7 +202,7 @@ Split query
.ToPageList(1,2); 
```
### Feature9 Big data insert or update
### Feature10 Big data insert or update
```cs
//Insert A million only takes a few seconds
db.Fastest<RealmAuctionDatum>().BulkCopy(GetList());