mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
-
This commit is contained in:
@@ -46,6 +46,10 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
db.ConfigQuery.SetTable<DataDictionary>(it => it.Code, it => it.Name, type, it => it.Type == type);
|
db.ConfigQuery.SetTable<DataDictionary>(it => it.Code, it => it.Name, type, it => it.Type == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, "01", it => it.Id > 1);
|
||||||
|
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, "02", it => it.Id > 2);
|
||||||
|
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,12 +63,7 @@ namespace OrmTest
|
|||||||
|
|
||||||
|
|
||||||
db.DbMaintenance.TruncateTable("DataDictionary");
|
db.DbMaintenance.TruncateTable("DataDictionary");
|
||||||
if (!db.ConfigQuery.Any())
|
|
||||||
{
|
|
||||||
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, "01", it => it.Id > 1);
|
|
||||||
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, "02", it => it.Id > 2);
|
|
||||||
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, null);
|
|
||||||
}
|
|
||||||
var list = db.Queryable<OrderItem>().Select(it => new OrderItem
|
var list = db.Queryable<OrderItem>().Select(it => new OrderItem
|
||||||
{
|
{
|
||||||
ItemId = it.ItemId.SelectAll(),
|
ItemId = it.ItemId.SelectAll(),
|
||||||
|
@@ -14,12 +14,23 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
Console.WriteLine("#### SimpleClient Start ####");
|
Console.WriteLine("#### SimpleClient Start ####");
|
||||||
var rep1=new Repository<C1Table>();
|
new C1Service().Test();
|
||||||
rep1.GetList();
|
|
||||||
var rep2 = rep1.ChangeRepository<Repository<C2Table>>();
|
|
||||||
Console.WriteLine("#### SimpleClient End ####");
|
Console.WriteLine("#### SimpleClient End ####");
|
||||||
}
|
}
|
||||||
|
public class C1Service : Repository<C1Table>
|
||||||
|
{
|
||||||
|
public void Test()
|
||||||
|
{
|
||||||
|
base.GetList();
|
||||||
|
base.ChangeRepository<C2Service>().GetList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class C2Service : Repository<C2Table>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class Repository<T> : SimpleClient<T> where T : class, new()
|
public class Repository<T> : SimpleClient<T> where T : class, new()
|
||||||
{
|
{
|
||||||
public Repository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
|
public Repository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
|
||||||
@@ -31,7 +42,6 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
ConfigId=1,
|
ConfigId=1,
|
||||||
DbType = SqlSugar.DbType.SqlServer,
|
DbType = SqlSugar.DbType.SqlServer,
|
||||||
InitKeyType = InitKeyType.Attribute,
|
|
||||||
IsAutoCloseConnection = true,
|
IsAutoCloseConnection = true,
|
||||||
ConnectionString = Config.ConnectionString
|
ConnectionString = Config.ConnectionString
|
||||||
},
|
},
|
||||||
@@ -39,7 +49,6 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
ConfigId="2",
|
ConfigId="2",
|
||||||
DbType = SqlSugar.DbType.SqlServer,
|
DbType = SqlSugar.DbType.SqlServer,
|
||||||
InitKeyType = InitKeyType.Attribute,
|
|
||||||
IsAutoCloseConnection = true,
|
IsAutoCloseConnection = true,
|
||||||
ConnectionString = Config.ConnectionString2
|
ConnectionString = Config.ConnectionString2
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user