mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Update README.md
This commit is contained in:
parent
83c20bc8cb
commit
35ab5c84d6
40
README.md
40
README.md
@ -18,6 +18,46 @@ Install-Package sqlSugar
|
|||||||
```ps1
|
```ps1
|
||||||
Install-Package sqlSugarCore
|
Install-Package sqlSugarCore
|
||||||
```
|
```
|
||||||
|
## Create SqlSugarClient
|
||||||
|
All operations are based on SqlSugarClient
|
||||||
|
```cs
|
||||||
|
public List<Student> GetStudentList()
|
||||||
|
{
|
||||||
|
var db= GetInstance();
|
||||||
|
var list= db.Queryable<Student>().ToList();//Search
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create SqlSugarClient
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = "Server=.xxxxx",
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
InitKeyType = InitKeyType.Attribute
|
||||||
|
});
|
||||||
|
//Print sql
|
||||||
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||||
|
Console.WriteLine();
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Student
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? SchoolId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## SqlSugar's 16 Functions
|
## SqlSugar's 16 Functions
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user