using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Dynamic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace SqlSugar { public partial class SqlSugarScope: ISqlSugarClient, ITenant { private SqlSugarScope() { } public SqlSugarScope(ConnectionConfig config) { _configs=new List() { config}; } public SqlSugarScope(List configs) { _configs = configs; } public SqlSugarScope(ConnectionConfig config, Action configAction) { _configs = new List() { config }; this._configAction = configAction; } public SqlSugarScope(List configs, Action configAction) { _configs = configs; this._configAction = configAction; } public SqlSugarClient ScopedContext{ get{ return GetContext();}} public SugarActionType SugarActionType { get => ScopedContext.SugarActionType;set=> ScopedContext.SugarActionType=value; } public MappingTableList MappingTables { get => ScopedContext.MappingTables; set => ScopedContext.MappingTables = value; } public MappingColumnList MappingColumns { get => ScopedContext.MappingColumns; set => ScopedContext.MappingColumns=value; } public IgnoreColumnList IgnoreColumns { get => ScopedContext.IgnoreColumns; set => ScopedContext.IgnoreColumns=value; } public IgnoreColumnList IgnoreInsertColumns { get => ScopedContext.IgnoreInsertColumns; set => ScopedContext.IgnoreInsertColumns=value; } public Dictionary TempItems { get => ScopedContext.TempItems; set => ScopedContext.TempItems=value; } public ConfigQuery ConfigQuery { get => ScopedContext.ConfigQuery; set => ScopedContext.ConfigQuery = value; } public bool IsSystemTablesConfig => ScopedContext.IsSystemTablesConfig; public Guid ContextID { get => ScopedContext.ContextID; set => ScopedContext.ContextID=value; } public ConnectionConfig CurrentConnectionConfig { get => ScopedContext.CurrentConnectionConfig; set => ScopedContext.CurrentConnectionConfig=value; } public IAdo Ado => ScopedContext.Ado; public AopProvider Aop => ScopedContext.Aop; public ICodeFirst CodeFirst => ScopedContext.CodeFirst; public IDbFirst DbFirst => ScopedContext.DbFirst; public IDbMaintenance DbMaintenance => ScopedContext.DbMaintenance; public EntityMaintenance EntityMaintenance { get => ScopedContext.EntityMaintenance; set => ScopedContext.EntityMaintenance=value; } public QueryFilterProvider QueryFilter { get => ScopedContext.QueryFilter; set => ScopedContext.QueryFilter=value; } public IContextMethods Utilities { get => ScopedContext.Utilities; set => ScopedContext.Utilities=value; } public QueueList Queues { get => ScopedContext.Queues; set => ScopedContext.Queues=value; } public SugarCacheProvider DataCache => ScopedContext.DataCache; public ITenant AsTenant() { return ScopedContext.AsTenant(); } public void AddConnection(ConnectionConfig connection) { ScopedContext.AddConnection(connection); } public void AddQueue(string sql, object parsmeters = null) { ScopedContext.AddQueue(sql, parsmeters); } public void AddQueue(string sql, List parsmeters) { ScopedContext.AddQueue(sql,parsmeters); } public void AddQueue(string sql, SugarParameter parsmeter) { ScopedContext.AddQueue(sql,parsmeter); } public void BeginTran() { ScopedContext.BeginTran(); } public void BeginTran(IsolationLevel iso) { ScopedContext.BeginTran(iso); } public Task BeginTranAsync() { return ScopedContext.BeginTranAsync(); } public async Task BeginTranAsync(IsolationLevel iso) { await ScopedContext.BeginTranAsync(iso); } public void ChangeDatabase(object configId) { ScopedContext.ChangeDatabase(configId); } public void ChangeDatabase(Func changeExpression) { ScopedContext.ChangeDatabase(changeExpression); } public void Close() { ScopedContext.Close(); } public void CommitTran() { ScopedContext.CommitTran(); } public Task CommitTranAsync() { return ScopedContext.CommitTranAsync(); } public DeleteMethodInfo DeleteableByObject(object singleEntityObjectOrListObject) { return ScopedContext.DeleteableByObject(singleEntityObjectOrListObject); } public IDeleteable Deleteable() where T : class, new() { return ScopedContext.Deleteable(); } public IDeleteable Deleteable(dynamic primaryKeyValue) where T : class, new() { return ScopedContext.Deleteable(primaryKeyValue); } public IDeleteable Deleteable(dynamic[] primaryKeyValues) where T : class, new() { return ScopedContext.Deleteable(primaryKeyValues); } public IDeleteable Deleteable(Expression> expression) where T : class, new() { return ScopedContext.Deleteable(expression); } public IDeleteable Deleteable(List pkValue) where T : class, new() { return ScopedContext.Deleteable(pkValue); } public IDeleteable Deleteable(List deleteObjs) where T : class, new() { return ScopedContext.Deleteable(deleteObjs); } public IDeleteable Deleteable(T deleteObj) where T : class, new() { return ScopedContext.Deleteable(deleteObj); } public void Dispose() { ScopedContext.Dispose(); } public SqlSugarProvider GetConnection(object configId) { return ScopedContext.GetConnection(configId); } public SqlSugarScopeProvider GetConnectionScope(object configId) { return ScopedContext.GetConnectionScope(configId); } public SqlSugarProvider GetConnectionWithAttr() { return ScopedContext.GetConnectionWithAttr(); } public SqlSugarScopeProvider GetConnectionScopeWithAttr() { return ScopedContext.GetConnectionScopeWithAttr(); } public DateTime GetDate() { return ScopedContext.GetDate(); } public T CreateContext(bool isTran = true) where T : SugarUnitOfWork, new() { return ScopedContext.CreateContext(isTran); } public SugarUnitOfWork CreateContext(bool isTran = true) { return ScopedContext.CreateContext(isTran); } public SimpleClient GetSimpleClient() where T : class, new() { return ScopedContext.GetSimpleClient(); } public RepositoryType GetRepository() where RepositoryType : ISugarRepository, new() { return ScopedContext.GetRepository(); } public void InitMappingInfo(Type type) { ScopedContext.InitMappingInfo(type); } public void InitMappingInfo() { ScopedContext.InitMappingInfo(); } public IInsertable> InsertableByDynamic(object insertDynamicObject) { return ScopedContext.InsertableByDynamic(insertDynamicObject); } public IInsertable Insertable(Dictionary columnDictionary) where T : class, new() { return ScopedContext.Insertable(columnDictionary); } public IInsertable Insertable(dynamic insertDynamicObject) where T : class, new() { return ScopedContext.Insertable((object)insertDynamicObject); } public IInsertable Insertable(List insertObjs) where T : class, new() { return ScopedContext.Insertable(insertObjs); } public IInsertable Insertable(T insertObj) where T : class, new() { return ScopedContext.Insertable(insertObj); } public IInsertable Insertable(T[] insertObjs) where T : class, new() { return ScopedContext.Insertable(insertObjs); } public InsertMethodInfo InsertableByObject(object singleEntityObjectOrListObject) { return ScopedContext.InsertableByObject(singleEntityObjectOrListObject); } public void Open() { ScopedContext.Open(); } public ISugarQueryable SlaveQueryable() { return ScopedContext.SlaveQueryable(); } public ISugarQueryable MasterQueryable() { return ScopedContext.MasterQueryable(); } public ISugarQueryable Queryable(string tableName, string shortName) { return ScopedContext.Queryable(tableName,shortName); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) where T : class, new() { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(Expression> joinExpression) { return ScopedContext.Queryable(joinExpression); } public ISugarQueryable Queryable(ISugarQueryable joinQueryable1, ISugarQueryable joinQueryable2, Expression> joinExpression) where T : class, new() where T2 : class, new() { return ScopedContext.Queryable(joinQueryable1,joinQueryable2, joinExpression); } public ISugarQueryable Queryable(ISugarQueryable joinQueryable1, ISugarQueryable joinQueryable2, JoinType joinType, Expression> joinExpression) where T : class, new() where T2 : class, new() { return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinType, joinExpression); } public ISugarQueryable Queryable(ISugarQueryable joinQueryable1, ISugarQueryable joinQueryable2, ISugarQueryable joinQueryable3, JoinType joinType1, Expression> joinExpression1, JoinType joinType2, Expression> joinExpression2) where T : class, new() where T2 : class, new() where T3 : class, new() { return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinQueryable3,joinType1,joinExpression1,joinType2,joinExpression2); } public ISugarQueryable Queryable(ISugarQueryable joinQueryable1, ISugarQueryable joinQueryable2, ISugarQueryable joinQueryable3, ISugarQueryable joinQueryable4, JoinType joinType1, Expression> joinExpression1, JoinType joinType2, Expression> joinExpression2, JoinType joinType3, Expression> joinExpression3) where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() { return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinQueryable3, joinQueryable4, joinType1, joinExpression1, joinType2, joinExpression2, joinType3, joinExpression3); } public ISugarQueryable Queryable() { return ScopedContext.Queryable(); } public ISugarQueryable Queryable(ISugarQueryable queryable) { return ScopedContext.Queryable(queryable); } public ISugarQueryable Queryable(ISugarQueryable queryable, string shortName) { return ScopedContext.Queryable(queryable, shortName); } public ISugarQueryable Queryable(string shortName) { return ScopedContext.Queryable(shortName); } public IReportable Reportable(T data) { return ScopedContext.Reportable(data); } public IReportable Reportable(List list) { return ScopedContext.Reportable(list); } public IReportable Reportable(T[] array) { return ScopedContext.Reportable(array); } public void RollbackTran() { ScopedContext.RollbackTran(); } public Task RollbackTranAsync() { return ScopedContext.RollbackTranAsync(); } [Obsolete("use Storageable")] public ISaveable Saveable(List saveObjects) where T : class, new() { return ScopedContext.Saveable(saveObjects); } [Obsolete("use Storageable")] public ISaveable Saveable(T saveObject) where T : class, new() { return ScopedContext.Saveable(saveObject); } public int SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List, List, List, List, List, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List, List, List, List, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List, List, List, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List, List, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Tuple, List> SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public List SaveQueues(bool isTran = true) { return ScopedContext.SaveQueues(isTran); } public Task SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List, List, List, List, List, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List, List, List, List, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List, List, List, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List, List, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task, List>> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public Task> SaveQueuesAsync(bool isTran = true) { return ScopedContext.SaveQueuesAsync(isTran); } public ISugarQueryable SqlQueryable(string sql) where T : class, new() { return ScopedContext.SqlQueryable(sql); } public IStorageable Storageable(T[] dataList) where T : class, new() { return ScopedContext.Storageable(dataList); } public StorageableDataTable Storageable(List> dictionaryList, string tableName) { return ScopedContext.Storageable(dictionaryList, tableName); } public StorageableDataTable Storageable(Dictionary dictionary, string tableName) { return ScopedContext.Storageable(dictionary, tableName); } public IStorageable Storageable(List dataList) where T : class, new() { return ScopedContext.Storageable(dataList); } public IStorageable Storageable(IList dataList) where T : class, new() { return ScopedContext.Storageable(dataList?.ToList()); } public IStorageable Storageable(T data) where T : class, new() { return ScopedContext.Storageable(data); } public StorageableDataTable Storageable(DataTable data) { return ScopedContext.Storageable(data); } public StorageableMethodInfo StorageableByObject(object singleEntityObjectOrListObject) { return this.ScopedContext.StorageableByObject(singleEntityObjectOrListObject); } public ISugarQueryable Union(List> queryables) where T : class, new() { return ScopedContext.Union(queryables); } public ISugarQueryable Union(params ISugarQueryable[] queryables) where T : class, new() { return ScopedContext.Union(queryables); } public ISugarQueryable UnionAll(List> queryables) where T : class, new() { return ScopedContext.UnionAll(queryables); } public ISugarQueryable UnionAll(params ISugarQueryable[] queryables) where T : class, new() { return ScopedContext.UnionAll(queryables); } public UpdateMethodInfo UpdateableByObject(object singleEntityObjectOrListObject) { return ScopedContext.UpdateableByObject(singleEntityObjectOrListObject); } public UpdateExpressionMethodInfo UpdateableByObject(Type entityType) { return ScopedContext.UpdateableByObject(entityType); } public IUpdateable> UpdateableByDynamic(object updateDynamicObject) { return ScopedContext.UpdateableByDynamic(updateDynamicObject); } public IUpdateable Updateable() where T : class, new() { return ScopedContext.Updateable(); } public IUpdateable Updateable(Dictionary columnDictionary) where T : class, new() { return ScopedContext.Updateable(columnDictionary); } public IUpdateable Updateable(dynamic updateDynamicObject) where T : class, new() { return ScopedContext.Updateable((object)updateDynamicObject); } public IUpdateable Updateable(Expression> columns) where T : class, new() { return ScopedContext.Updateable(columns); } public IUpdateable Updateable(Expression> columns) where T : class, new() { return ScopedContext.Updateable(columns); } public IUpdateable Updateable(List UpdateObjs) where T : class, new() { return ScopedContext.Updateable(UpdateObjs); } public IUpdateable Updateable(T UpdateObj) where T : class, new() { return ScopedContext.Updateable(UpdateObj); } public IUpdateable Updateable(T[] UpdateObjs) where T : class, new() { return ScopedContext.Updateable(UpdateObjs); } public SplitTableContext SplitHelper() where T : class, new() { return ScopedContext.SplitHelper(); } public SplitTableContext SplitHelper(Type entityType) { return ScopedContext.SplitHelper(entityType); } public SplitTableContextResult SplitHelper(T data) where T : class, new() { return ScopedContext.SplitHelper(data); } public SplitTableContextResult SplitHelper(List dataList) where T : class, new() { return ScopedContext.SplitHelper(dataList); } public SqlSugarTransaction UseTran() { return ScopedContext.UseTran(); } public DbResult UseTran(Action action, Action errorCallBack = null) { return ScopedContext.UseTran(action,errorCallBack); } public DbResult UseTran(Func action, Action errorCallBack = null) { return ScopedContext.UseTran(action,errorCallBack); } public Task> UseTranAsync(Func action, Action errorCallBack = null) { return ScopedContext.UseTranAsync(action, errorCallBack); } public Task> UseTranAsync(Func> action, Action errorCallBack = null) { return ScopedContext.UseTranAsync(action, errorCallBack); } public bool IsAnyConnection(object configId) { return ScopedContext.IsAnyConnection(configId); } public IFastest Fastest() where T : class, new() { return ScopedContext.Fastest(); } public void ThenMapper(IEnumerable list, Action action) { ScopedContext.ThenMapper(list, action); } public Task ThenMapperAsync(IEnumerable list, Func action) { return ScopedContext.ThenMapperAsync(list, action); } public ISugarQueryable QueryableWithAttr() { return ScopedContext.QueryableWithAttr(); } public IInsertable InsertableWithAttr(T insertObj) where T : class, new() { return ScopedContext.InsertableWithAttr(insertObj); } public IInsertable InsertableWithAttr(List insertObjs) where T : class, new() { return ScopedContext.InsertableWithAttr(insertObjs); } public IUpdateable UpdateableWithAttr(T updateObj) where T : class, new() { return ScopedContext.UpdateableWithAttr(updateObj); } public IUpdateable UpdateableWithAttr() where T : class, new() { return ScopedContext.UpdateableWithAttr(); } public IUpdateable UpdateableWithAttr(List updateObjs) where T : class, new() { return ScopedContext.UpdateableWithAttr(updateObjs); } public IDeleteable DeleteableWithAttr(T deleteObj) where T : class, new() { return ScopedContext.DeleteableWithAttr(deleteObj); } public IDeleteable DeleteableWithAttr() where T : class, new() { return ScopedContext.DeleteableWithAttr(); } public IDeleteable DeleteableWithAttr(List deleteObjs) where T : class, new() { return ScopedContext.DeleteableWithAttr(deleteObjs); } public InsertNavTaskInit InsertNav(T data) where T : class, new() { return ScopedContext.InsertNav(data); } public InsertNavTaskInit InsertNav(List datas) where T : class, new() { return ScopedContext.InsertNav(datas); } public InsertNavTaskInit InsertNav(T data, InsertNavRootOptions rootOptions) where T : class, new() { return ScopedContext.InsertNav(data, rootOptions); } public InsertNavTaskInit InsertNav(List datas, InsertNavRootOptions rootOptions) where T : class, new() { return ScopedContext.InsertNav(datas, rootOptions); } public DeleteNavTaskInit DeleteNav(T data) where T : class, new() { return ScopedContext.DeleteNav(data); } public DeleteNavTaskInit DeleteNav(List datas) where T : class, new() { return ScopedContext.DeleteNav(datas); } public DeleteNavTaskInit DeleteNav(Expression> whereExpression) where T : class, new() { return ScopedContext.DeleteNav(whereExpression); } public DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new() { return ScopedContext.DeleteNav(data, options); } public DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new() { return ScopedContext.DeleteNav(datas, options); } public DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new() { return ScopedContext.DeleteNav(whereExpression, options); } public UpdateNavTaskInit UpdateNav(T data) where T : class, new() { return ScopedContext.UpdateNav(data); } public UpdateNavTaskInit UpdateNav(List datas) where T : class, new() { return ScopedContext.UpdateNav(datas); } public UpdateNavTaskInit UpdateNav(T data,UpdateNavRootOptions rootOptions) where T : class, new() { return ScopedContext.UpdateNav(data, rootOptions); } public UpdateNavTaskInit UpdateNav(List datas, UpdateNavRootOptions rootOptions) where T : class, new() { return ScopedContext.UpdateNav(datas, rootOptions); } public SqlSugarClient CopyNew() { var result= new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig)); result.QueryFilter = this.QueryFilter; if (this.ScopedContext._AllClients != null) { foreach (var item in this.ScopedContext._AllClients) { if (!result.IsAnyConnection(item.ConnectionConfig.ConfigId)) { result.AddConnection(UtilMethods.CopyConfig(item.ConnectionConfig)); } } } return result; } public DynamicBuilder DynamicBuilder() { return ScopedContext.DynamicBuilder(); } public void Tracking(T data) where T : class, new() { ScopedContext.Tracking(data); } public void Tracking(List datas) where T : class, new() { ScopedContext.Tracking(datas); } public void RemoveConnection(dynamic configId) { ScopedContext.RemoveConnection(configId); } public Task AsyncLock(int timeOutSeconds=30) { return ScopedContext.AsyncLock(timeOutSeconds); } public QueryMethodInfo QueryableByObject(Type entityType) { return ScopedContext.QueryableByObject(entityType); } public QueryMethodInfo QueryableByObject(Type entityType, string shortName) { return ScopedContext.QueryableByObject(entityType, shortName); } public GridSaveProvider GridSave(List oldList, List saveList) where T : class, new() { return ScopedContext.GridSave(oldList, saveList); } public GridSaveProvider GridSave(List saveList) where T : class, new() { return ScopedContext.GridSave(saveList); } public void ClearTracking() { ScopedContext.ClearTracking(); } } }