mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 20:43:46 +08:00
Add SimpleClient.ChangeRepository
This commit is contained in:
@@ -22,8 +22,10 @@ namespace OrmTest
|
||||
}
|
||||
public class OrderDal:Repository<Order>
|
||||
{
|
||||
public void MyTest() {
|
||||
|
||||
public void MyTest()
|
||||
{
|
||||
base.CommQuery("1=1");
|
||||
base.ChangeRepository<Repository<OrderItem>>().CommQuery("1=1");
|
||||
}
|
||||
}
|
||||
public class Repository<T> : SimpleClient<T> where T : class, new()
|
||||
@@ -32,13 +34,18 @@ namespace OrmTest
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
base.Context = new SqlSugarClient(new ConnectionConfig()
|
||||
var db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = SqlSugar.DbType.SqlServer,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
ConnectionString = Config.ConnectionString
|
||||
});
|
||||
base.Context = db;
|
||||
db.Aop.OnLogExecuting = (s, p) =>
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +53,10 @@ namespace OrmTest
|
||||
/// 扩展方法,自带方法不能满足的时候可以添加新方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<T> CommQuery(string json)
|
||||
public List<T> CommQuery(string sql)
|
||||
{
|
||||
//base.Context.Queryable<T>().ToList();可以拿到SqlSugarClient 做复杂操作
|
||||
return null;
|
||||
return base.Context.Queryable<T>().Where(sql).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user