mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Add demo
This commit is contained in:
parent
9a113c6292
commit
3dbf85df7b
@ -18,6 +18,18 @@ namespace OrmTest
|
||||
order.GetList();
|
||||
order.GetById(1);
|
||||
order.MyTest();
|
||||
|
||||
var db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = SqlSugar.DbType.SqlServer,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
ConnectionString = Config.ConnectionString
|
||||
});
|
||||
var repository= db.GetRepository<Repository<Order>>();
|
||||
var list=repository.GetList();
|
||||
var repository2 = db.GetRepository<SimpleClient<Order>>();
|
||||
var list2 = repository2.GetList();
|
||||
Console.WriteLine("#### SimpleClient End ####");
|
||||
}
|
||||
public class OrderDal:Repository<Order>
|
||||
@ -30,9 +42,7 @@ namespace OrmTest
|
||||
}
|
||||
public class Repository<T> : SimpleClient<T> where T : class, new()
|
||||
{
|
||||
public Repository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
|
||||
{
|
||||
if (context == null)
|
||||
public Repository()
|
||||
{
|
||||
var db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
@ -47,7 +57,6 @@ namespace OrmTest
|
||||
Console.WriteLine(s);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扩展方法,自带方法不能满足的时候可以添加新方法
|
||||
|
Loading…
Reference in New Issue
Block a user