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