mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-09 10:55:02 +08:00
Update README.md
This commit is contained in:
87
README.md
87
README.md
@@ -285,49 +285,29 @@ db.Saveable<Student>(new Student() { Name = "" })
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 9.EntityMain
|
||||||
##### Priority level:
|
## 10.DbMain
|
||||||
AS>Add>Attribute
|
## 11.AOP
|
||||||
### 5.1 Add
|
|
||||||
```cs
|
```cs
|
||||||
db.MappingTables.Add()
|
db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
|
||||||
db.MappingColumns.Add()
|
|
||||||
db.IgnoreColumns.Add()
|
|
||||||
```
|
|
||||||
### 5.2 AS
|
|
||||||
```cs
|
|
||||||
db.Queryable<T>().As("tableName").ToList();
|
|
||||||
```
|
|
||||||
### 5.3 Attribute
|
|
||||||
```cs
|
|
||||||
[SugarColumn(IsIgnore=true)]
|
|
||||||
public int TestId { get; set; }
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. Use Tran
|
|
||||||
```cs
|
|
||||||
var result = db.Ado.UseTran(() =>
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
db.Aop.OnError = (exp) =>//SQL execution error event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
db.Aop.OnExecutingChangeSql = (sql, pars) => //SQL executing event (pre-execution,SQL script can be modified)
|
||||||
|
{
|
||||||
|
return new KeyValuePair<string, SugarParameter[]>(sql,pars);
|
||||||
|
};
|
||||||
|
|
||||||
var beginCount = db.Queryable<Student>().ToList();
|
|
||||||
db.Ado.ExecuteCommand("delete student");
|
|
||||||
var endCount = db.Queryable<Student>().Count();
|
|
||||||
throw new Exception("error haha");
|
|
||||||
})
|
|
||||||
//result.IsSucces
|
|
||||||
//result.XXX
|
|
||||||
```
|
```
|
||||||
## 7. Use Store Procedure
|
## 12.Db First
|
||||||
```cs
|
|
||||||
var dt2 = db.Ado.UseStoredProcedure().GetDataTable("sp_school",new{p1=1,p2=null});
|
|
||||||
|
|
||||||
//output
|
|
||||||
var p11 = new SugarParameter("@p1", "1");
|
|
||||||
var p22 = new SugarParameter("@p2", null, true);//isOutput=true
|
|
||||||
var dt2 = db.Ado.UseStoredProcedure().GetDataTable("sp_school",p11,p22);
|
|
||||||
```
|
|
||||||
|
|
||||||
## 8. DbFirst
|
|
||||||
```cs
|
```cs
|
||||||
var db = GetInstance();
|
var db = GetInstance();
|
||||||
//Create all class
|
//Create all class
|
||||||
@@ -387,32 +367,15 @@ db.DbFirst
|
|||||||
.CreateClassFile("c:\\Demo\\6");
|
.CreateClassFile("c:\\Demo\\6");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 8.Code First
|
## 13.Code First
|
||||||
```cs
|
```cs
|
||||||
db.CodeFirst.BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2)); //change entity backupTable
|
db.CodeFirst.SetStringDefaultLength(100).BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2)); //change entity backupTable
|
||||||
db.CodeFirst.InitTables(typeof(CodeTable),typeof(CodeTable2));
|
db.CodeFirst.SetStringDefaultLength(100).InitTables(typeof(CodeTable), typeof(CodeTable2));
|
||||||
```
|
```
|
||||||
|
## 14.Utilities
|
||||||
|
## 15.Gobal Filter
|
||||||
|
## 16.Gobal Filter
|
||||||
|
|
||||||
## 9. AOP LOG
|
|
||||||
```cs
|
|
||||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
db.Aop.OnError = (exp) =>//SQL execution error event
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
db.Aop.OnExecutingChangeSql = (sql, pars) => //SQL executing event (pre-execution,SQL script can be modified)
|
|
||||||
{
|
|
||||||
return new KeyValuePair<string, SugarParameter[]>(sql,pars);
|
|
||||||
};
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## 10. Code generator
|
## 10. Code generator
|
||||||
https://github.com/sunkaixuan/SoEasyPlatform
|
https://github.com/sunkaixuan/SoEasyPlatform
|
||||||
|
|||||||
Reference in New Issue
Block a user