SqlSugarScope.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Diagnostics;
  5. using System.Dynamic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace SqlSugar
  11. {
  12. public partial class SqlSugarScope: ISqlSugarClient, ITenant
  13. {
  14. private SqlSugarScope()
  15. {
  16. }
  17. public SqlSugarScope(ConnectionConfig config)
  18. {
  19. _configs=new List<ConnectionConfig>() { config};
  20. }
  21. public SqlSugarScope(List<ConnectionConfig> configs)
  22. {
  23. _configs = configs;
  24. }
  25. public SqlSugarScope(ConnectionConfig config, Action<SqlSugarClient> configAction)
  26. {
  27. _configs = new List<ConnectionConfig>() { config };
  28. this._configAction = configAction;
  29. }
  30. public SqlSugarScope(List<ConnectionConfig> configs, Action<SqlSugarClient> configAction)
  31. {
  32. _configs = configs;
  33. this._configAction = configAction;
  34. }
  35. public SqlSugarClient ScopedContext{ get{ return GetContext();}}
  36. public SugarActionType SugarActionType { get => ScopedContext.SugarActionType;set=> ScopedContext.SugarActionType=value; }
  37. public MappingTableList MappingTables { get => ScopedContext.MappingTables; set => ScopedContext.MappingTables = value; }
  38. public MappingColumnList MappingColumns { get => ScopedContext.MappingColumns; set => ScopedContext.MappingColumns=value; }
  39. public IgnoreColumnList IgnoreColumns { get => ScopedContext.IgnoreColumns; set => ScopedContext.IgnoreColumns=value; }
  40. public IgnoreColumnList IgnoreInsertColumns { get => ScopedContext.IgnoreInsertColumns; set => ScopedContext.IgnoreInsertColumns=value; }
  41. public Dictionary<string, object> TempItems { get => ScopedContext.TempItems; set => ScopedContext.TempItems=value; }
  42. public ConfigQuery ConfigQuery { get => ScopedContext.ConfigQuery; set => ScopedContext.ConfigQuery = value; }
  43. public bool IsSystemTablesConfig => ScopedContext.IsSystemTablesConfig;
  44. public Guid ContextID { get => ScopedContext.ContextID; set => ScopedContext.ContextID=value; }
  45. public ConnectionConfig CurrentConnectionConfig { get => ScopedContext.CurrentConnectionConfig; set => ScopedContext.CurrentConnectionConfig=value; }
  46. public IAdo Ado => ScopedContext.Ado;
  47. public AopProvider Aop => ScopedContext.Aop;
  48. public ICodeFirst CodeFirst => ScopedContext.CodeFirst;
  49. public IDbFirst DbFirst => ScopedContext.DbFirst;
  50. public IDbMaintenance DbMaintenance => ScopedContext.DbMaintenance;
  51. public EntityMaintenance EntityMaintenance { get => ScopedContext.EntityMaintenance; set => ScopedContext.EntityMaintenance=value; }
  52. public QueryFilterProvider QueryFilter { get => ScopedContext.QueryFilter; set => ScopedContext.QueryFilter=value; }
  53. public IContextMethods Utilities { get => ScopedContext.Utilities; set => ScopedContext.Utilities=value; }
  54. public QueueList Queues { get => ScopedContext.Queues; set => ScopedContext.Queues=value; }
  55. public SugarCacheProvider DataCache => ScopedContext.DataCache;
  56. public ITenant AsTenant()
  57. {
  58. return ScopedContext.AsTenant();
  59. }
  60. public void AddConnection(ConnectionConfig connection)
  61. {
  62. ScopedContext.AddConnection(connection);
  63. }
  64. public void AddQueue(string sql, object parsmeters = null)
  65. {
  66. ScopedContext.AddQueue(sql, parsmeters);
  67. }
  68. public void AddQueue(string sql, List<SugarParameter> parsmeters)
  69. {
  70. ScopedContext.AddQueue(sql,parsmeters);
  71. }
  72. public void AddQueue(string sql, SugarParameter parsmeter)
  73. {
  74. ScopedContext.AddQueue(sql,parsmeter);
  75. }
  76. public void BeginTran()
  77. {
  78. ScopedContext.BeginTran();
  79. }
  80. public void BeginTran(IsolationLevel iso)
  81. {
  82. ScopedContext.BeginTran(iso);
  83. }
  84. public Task BeginTranAsync()
  85. {
  86. return ScopedContext.BeginTranAsync();
  87. }
  88. public async Task BeginTranAsync(IsolationLevel iso)
  89. {
  90. await ScopedContext.BeginTranAsync(iso);
  91. }
  92. public void ChangeDatabase(object configId)
  93. {
  94. ScopedContext.ChangeDatabase(configId);
  95. }
  96. public void ChangeDatabase(Func<ConnectionConfig, bool> changeExpression)
  97. {
  98. ScopedContext.ChangeDatabase(changeExpression);
  99. }
  100. public void Close()
  101. {
  102. ScopedContext.Close();
  103. }
  104. public void CommitTran()
  105. {
  106. ScopedContext.CommitTran();
  107. }
  108. public Task CommitTranAsync()
  109. {
  110. return ScopedContext.CommitTranAsync();
  111. }
  112. public DeleteMethodInfo DeleteableByObject(object singleEntityObjectOrListObject)
  113. {
  114. return ScopedContext.DeleteableByObject(singleEntityObjectOrListObject);
  115. }
  116. public IDeleteable<T> Deleteable<T>() where T : class, new()
  117. {
  118. return ScopedContext.Deleteable<T>();
  119. }
  120. public IDeleteable<T> Deleteable<T>(dynamic primaryKeyValue) where T : class, new()
  121. {
  122. return ScopedContext.Deleteable<T>(primaryKeyValue);
  123. }
  124. public IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new()
  125. {
  126. return ScopedContext.Deleteable<T>(primaryKeyValues);
  127. }
  128. public IDeleteable<T> Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new()
  129. {
  130. return ScopedContext.Deleteable(expression);
  131. }
  132. public IDeleteable<T> Deleteable<T>(List<dynamic> pkValue) where T : class, new()
  133. {
  134. return ScopedContext.Deleteable<T>(pkValue);
  135. }
  136. public IDeleteable<T> Deleteable<T>(List<T> deleteObjs) where T : class, new()
  137. {
  138. return ScopedContext.Deleteable(deleteObjs);
  139. }
  140. public IDeleteable<T> Deleteable<T>(T deleteObj) where T : class, new()
  141. {
  142. return ScopedContext.Deleteable(deleteObj);
  143. }
  144. public void Dispose()
  145. {
  146. ScopedContext.Dispose();
  147. }
  148. public SqlSugarProvider GetConnection(object configId)
  149. {
  150. return ScopedContext.GetConnection(configId);
  151. }
  152. public SqlSugarScopeProvider GetConnectionScope(object configId)
  153. {
  154. return ScopedContext.GetConnectionScope(configId);
  155. }
  156. public SqlSugarProvider GetConnectionWithAttr<T>()
  157. {
  158. return ScopedContext.GetConnectionWithAttr<T>();
  159. }
  160. public SqlSugarScopeProvider GetConnectionScopeWithAttr<T>()
  161. {
  162. return ScopedContext.GetConnectionScopeWithAttr<T>();
  163. }
  164. public DateTime GetDate()
  165. {
  166. return ScopedContext.GetDate();
  167. }
  168. public T CreateContext<T>(bool isTran = true) where T : SugarUnitOfWork, new()
  169. {
  170. return ScopedContext.CreateContext<T>(isTran);
  171. }
  172. public SugarUnitOfWork CreateContext(bool isTran = true)
  173. {
  174. return ScopedContext.CreateContext(isTran);
  175. }
  176. public SimpleClient<T> GetSimpleClient<T>() where T : class, new()
  177. {
  178. return ScopedContext.GetSimpleClient<T>();
  179. }
  180. public RepositoryType GetRepository<RepositoryType>() where RepositoryType : ISugarRepository, new()
  181. {
  182. return ScopedContext.GetRepository<RepositoryType>();
  183. }
  184. public void InitMappingInfo(Type type)
  185. {
  186. ScopedContext.InitMappingInfo(type);
  187. }
  188. public void InitMappingInfo<T>()
  189. {
  190. ScopedContext.InitMappingInfo<T>();
  191. }
  192. public IInsertable<Dictionary<string, object>> InsertableByDynamic(object insertDynamicObject)
  193. {
  194. return ScopedContext.InsertableByDynamic(insertDynamicObject);
  195. }
  196. public IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
  197. {
  198. return ScopedContext.Insertable<T>(columnDictionary);
  199. }
  200. public IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
  201. {
  202. return ScopedContext.Insertable<T>((object)insertDynamicObject);
  203. }
  204. public IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new()
  205. {
  206. return ScopedContext.Insertable(insertObjs);
  207. }
  208. public IInsertable<T> Insertable<T>(T insertObj) where T : class, new()
  209. {
  210. return ScopedContext.Insertable(insertObj);
  211. }
  212. public IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new()
  213. {
  214. return ScopedContext.Insertable(insertObjs);
  215. }
  216. public InsertMethodInfo InsertableByObject(object singleEntityObjectOrListObject)
  217. {
  218. return ScopedContext.InsertableByObject(singleEntityObjectOrListObject);
  219. }
  220. public void Open()
  221. {
  222. ScopedContext.Open();
  223. }
  224. public ISugarQueryable<T> SlaveQueryable<T>()
  225. {
  226. return ScopedContext.SlaveQueryable<T>();
  227. }
  228. public ISugarQueryable<T> MasterQueryable<T>()
  229. {
  230. return ScopedContext.MasterQueryable<T>();
  231. }
  232. public ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName)
  233. {
  234. return ScopedContext.Queryable(tableName,shortName);
  235. }
  236. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression) where T : class, new()
  237. {
  238. return ScopedContext.Queryable(joinExpression);
  239. }
  240. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, JoinQueryInfos>> joinExpression)
  241. {
  242. return ScopedContext.Queryable(joinExpression);
  243. }
  244. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression)
  245. {
  246. return ScopedContext.Queryable(joinExpression);
  247. }
  248. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression) where T : class, new()
  249. {
  250. return ScopedContext.Queryable(joinExpression);
  251. }
  252. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, JoinQueryInfos>> joinExpression)
  253. {
  254. return ScopedContext.Queryable(joinExpression);
  255. }
  256. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression)
  257. {
  258. return ScopedContext.Queryable(joinExpression);
  259. }
  260. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression) where T : class, new()
  261. {
  262. return ScopedContext.Queryable(joinExpression);
  263. }
  264. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, JoinQueryInfos>> joinExpression)
  265. {
  266. return ScopedContext.Queryable(joinExpression);
  267. }
  268. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression)
  269. {
  270. return ScopedContext.Queryable(joinExpression);
  271. }
  272. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression) where T : class, new()
  273. {
  274. return ScopedContext.Queryable(joinExpression);
  275. }
  276. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, JoinQueryInfos>> joinExpression)
  277. {
  278. return ScopedContext.Queryable(joinExpression);
  279. }
  280. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression)
  281. {
  282. return ScopedContext.Queryable(joinExpression);
  283. }
  284. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression) where T : class, new()
  285. {
  286. return ScopedContext.Queryable(joinExpression);
  287. }
  288. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, JoinQueryInfos>> joinExpression)
  289. {
  290. return ScopedContext.Queryable(joinExpression);
  291. }
  292. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression)
  293. {
  294. return ScopedContext.Queryable(joinExpression);
  295. }
  296. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression) where T : class, new()
  297. {
  298. return ScopedContext.Queryable(joinExpression);
  299. }
  300. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, JoinQueryInfos>> joinExpression)
  301. {
  302. return ScopedContext.Queryable(joinExpression);
  303. }
  304. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression)
  305. {
  306. return ScopedContext.Queryable(joinExpression);
  307. }
  308. public ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression) where T : class, new()
  309. {
  310. return ScopedContext.Queryable(joinExpression);
  311. }
  312. public ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, JoinQueryInfos>> joinExpression)
  313. {
  314. return ScopedContext.Queryable(joinExpression);
  315. }
  316. public ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression)
  317. {
  318. return ScopedContext.Queryable(joinExpression);
  319. }
  320. public ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression) where T : class, new()
  321. {
  322. return ScopedContext.Queryable(joinExpression);
  323. }
  324. public ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, JoinQueryInfos>> joinExpression)
  325. {
  326. return ScopedContext.Queryable(joinExpression);
  327. }
  328. public ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression)
  329. {
  330. return ScopedContext.Queryable(joinExpression);
  331. }
  332. public ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpression) where T : class, new()
  333. {
  334. return ScopedContext.Queryable(joinExpression);
  335. }
  336. public ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, JoinQueryInfos>> joinExpression)
  337. {
  338. return ScopedContext.Queryable(joinExpression);
  339. }
  340. public ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression)
  341. {
  342. return ScopedContext.Queryable(joinExpression);
  343. }
  344. public ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, bool>> joinExpression) where T : class, new()
  345. {
  346. return ScopedContext.Queryable(joinExpression);
  347. }
  348. public ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, JoinQueryInfos>> joinExpression)
  349. {
  350. return ScopedContext.Queryable(joinExpression);
  351. }
  352. public ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression)
  353. {
  354. return ScopedContext.Queryable(joinExpression);
  355. }
  356. public ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, bool>> joinExpression) where T : class, new()
  357. {
  358. return ScopedContext.Queryable(joinExpression);
  359. }
  360. public ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, JoinQueryInfos>> joinExpression)
  361. {
  362. return ScopedContext.Queryable(joinExpression);
  363. }
  364. public ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, object[]>> joinExpression)
  365. {
  366. return ScopedContext.Queryable(joinExpression);
  367. }
  368. public ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, Expression<Func<T, T2, bool>> joinExpression)
  369. where T : class, new()
  370. where T2 : class, new()
  371. {
  372. return ScopedContext.Queryable(joinQueryable1,joinQueryable2, joinExpression);
  373. }
  374. public ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, JoinType joinType, Expression<Func<T, T2, bool>> joinExpression)
  375. where T : class, new()
  376. where T2 : class, new()
  377. {
  378. return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinType, joinExpression);
  379. }
  380. public ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, ISugarQueryable<T3> joinQueryable3, JoinType joinType1, Expression<Func<T, T2, T3, bool>> joinExpression1, JoinType joinType2, Expression<Func<T, T2, T3, bool>> joinExpression2)
  381. where T : class, new()
  382. where T2 : class, new()
  383. where T3 : class, new()
  384. {
  385. return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinQueryable3,joinType1,joinExpression1,joinType2,joinExpression2);
  386. }
  387. public ISugarQueryable<T, T2, T3,T4> Queryable<T, T2, T3, T4>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, ISugarQueryable<T3> joinQueryable3, ISugarQueryable<T4> joinQueryable4, JoinType joinType1, Expression<Func<T, T2, T3, T4, bool>> joinExpression1, JoinType joinType2, Expression<Func<T, T2, T3, T4, bool>> joinExpression2, JoinType joinType3, Expression<Func<T, T2, T3, T4, bool>> joinExpression3)
  388. where T : class, new()
  389. where T2 : class, new()
  390. where T3 : class, new()
  391. where T4 : class, new()
  392. {
  393. return ScopedContext.Queryable(joinQueryable1, joinQueryable2, joinQueryable3, joinQueryable4, joinType1, joinExpression1, joinType2, joinExpression2, joinType3, joinExpression3);
  394. }
  395. public ISugarQueryable<T> Queryable<T>()
  396. {
  397. return ScopedContext.Queryable<T>();
  398. }
  399. public ISugarQueryable<T> Queryable<T>(ISugarQueryable<T> queryable)
  400. {
  401. return ScopedContext.Queryable(queryable);
  402. }
  403. public ISugarQueryable<T> Queryable<T>(ISugarQueryable<T> queryable, string shortName)
  404. {
  405. return ScopedContext.Queryable(queryable, shortName);
  406. }
  407. public ISugarQueryable<T> Queryable<T>(string shortName)
  408. {
  409. return ScopedContext.Queryable<T>(shortName);
  410. }
  411. public IReportable<T> Reportable<T>(T data)
  412. {
  413. return ScopedContext.Reportable(data);
  414. }
  415. public IReportable<T> Reportable<T>(List<T> list)
  416. {
  417. return ScopedContext.Reportable(list);
  418. }
  419. public IReportable<T> Reportable<T>(T[] array)
  420. {
  421. return ScopedContext.Reportable(array);
  422. }
  423. public void RollbackTran()
  424. {
  425. ScopedContext.RollbackTran();
  426. }
  427. public Task RollbackTranAsync()
  428. {
  429. return ScopedContext.RollbackTranAsync();
  430. }
  431. [Obsolete("use Storageable")]
  432. public ISaveable<T> Saveable<T>(List<T> saveObjects) where T : class, new()
  433. {
  434. return ScopedContext.Saveable(saveObjects);
  435. }
  436. [Obsolete("use Storageable")]
  437. public ISaveable<T> Saveable<T>(T saveObject) where T : class, new()
  438. {
  439. return ScopedContext.Saveable(saveObject);
  440. }
  441. public int SaveQueues(bool isTran = true)
  442. {
  443. return ScopedContext.SaveQueues(isTran);
  444. }
  445. public Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>> SaveQueues<T, T2, T3, T4, T5, T6, T7>(bool isTran = true)
  446. {
  447. return ScopedContext.SaveQueues<T, T2, T3, T4, T5, T6, T7>(isTran);
  448. }
  449. public Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>> SaveQueues<T, T2, T3, T4, T5, T6>(bool isTran = true)
  450. {
  451. return ScopedContext.SaveQueues<T, T2, T3, T4, T5, T6>(isTran);
  452. }
  453. public Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>> SaveQueues<T, T2, T3, T4, T5>(bool isTran = true)
  454. {
  455. return ScopedContext.SaveQueues<T, T2, T3, T4, T5>(isTran);
  456. }
  457. public Tuple<List<T>, List<T2>, List<T3>, List<T4>> SaveQueues<T, T2, T3, T4>(bool isTran = true)
  458. {
  459. return ScopedContext.SaveQueues<T, T2, T3, T4>(isTran);
  460. }
  461. public Tuple<List<T>, List<T2>, List<T3>> SaveQueues<T, T2, T3>(bool isTran = true)
  462. {
  463. return ScopedContext.SaveQueues<T, T2, T3>(isTran);
  464. }
  465. public Tuple<List<T>, List<T2>> SaveQueues<T, T2>(bool isTran = true)
  466. {
  467. return ScopedContext.SaveQueues<T, T2>(isTran);
  468. }
  469. public List<T> SaveQueues<T>(bool isTran = true)
  470. {
  471. return ScopedContext.SaveQueues<T>(isTran);
  472. }
  473. public Task<int> SaveQueuesAsync(bool isTran = true)
  474. {
  475. return ScopedContext.SaveQueuesAsync(isTran);
  476. }
  477. public Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>> SaveQueuesAsync<T, T2, T3, T4, T5, T6, T7>(bool isTran = true)
  478. {
  479. return ScopedContext.SaveQueuesAsync<T, T2, T3, T4, T5, T6, T7>(isTran);
  480. }
  481. public Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>>> SaveQueuesAsync<T, T2, T3, T4, T5, T6>(bool isTran = true)
  482. {
  483. return ScopedContext.SaveQueuesAsync<T, T2, T3, T4, T5, T6>(isTran);
  484. }
  485. public Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>>> SaveQueuesAsync<T, T2, T3, T4, T5>(bool isTran = true)
  486. {
  487. return ScopedContext.SaveQueuesAsync<T, T2, T3, T4, T5>(isTran);
  488. }
  489. public Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>>> SaveQueuesAsync<T, T2, T3, T4>(bool isTran = true)
  490. {
  491. return ScopedContext.SaveQueuesAsync<T, T2, T3, T4>(isTran);
  492. }
  493. public Task<Tuple<List<T>, List<T2>, List<T3>>> SaveQueuesAsync<T, T2, T3>(bool isTran = true)
  494. {
  495. return ScopedContext.SaveQueuesAsync<T, T2, T3>(isTran);
  496. }
  497. public Task<Tuple<List<T>, List<T2>>> SaveQueuesAsync<T, T2>(bool isTran = true)
  498. {
  499. return ScopedContext.SaveQueuesAsync<T, T2>(isTran);
  500. }
  501. public Task<List<T>> SaveQueuesAsync<T>(bool isTran = true)
  502. {
  503. return ScopedContext.SaveQueuesAsync<T>(isTran);
  504. }
  505. public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new()
  506. {
  507. return ScopedContext.SqlQueryable<T>(sql);
  508. }
  509. public IStorageable<T> Storageable<T>(T[] dataList) where T : class, new()
  510. {
  511. return ScopedContext.Storageable(dataList);
  512. }
  513. public StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName)
  514. {
  515. return ScopedContext.Storageable(dictionaryList, tableName);
  516. }
  517. public StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName)
  518. {
  519. return ScopedContext.Storageable(dictionary, tableName);
  520. }
  521. public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
  522. {
  523. return ScopedContext.Storageable(dataList);
  524. }
  525. public IStorageable<T> Storageable<T>(IList<T> dataList) where T : class, new()
  526. {
  527. return ScopedContext.Storageable(dataList?.ToList());
  528. }
  529. public IStorageable<T> Storageable<T>(T data) where T : class, new()
  530. {
  531. return ScopedContext.Storageable(data);
  532. }
  533. public StorageableDataTable Storageable(DataTable data)
  534. {
  535. return ScopedContext.Storageable(data);
  536. }
  537. public StorageableMethodInfo StorageableByObject(object singleEntityObjectOrListObject)
  538. {
  539. return this.ScopedContext.StorageableByObject(singleEntityObjectOrListObject);
  540. }
  541. public ISugarQueryable<T> Union<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
  542. {
  543. return ScopedContext.Union(queryables);
  544. }
  545. public ISugarQueryable<T> Union<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
  546. {
  547. return ScopedContext.Union(queryables);
  548. }
  549. public ISugarQueryable<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
  550. {
  551. return ScopedContext.UnionAll(queryables);
  552. }
  553. public ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
  554. {
  555. return ScopedContext.UnionAll(queryables);
  556. }
  557. public UpdateMethodInfo UpdateableByObject(object singleEntityObjectOrListObject)
  558. {
  559. return ScopedContext.UpdateableByObject(singleEntityObjectOrListObject);
  560. }
  561. public UpdateExpressionMethodInfo UpdateableByObject(Type entityType)
  562. {
  563. return ScopedContext.UpdateableByObject(entityType);
  564. }
  565. public IUpdateable<Dictionary<string, object>> UpdateableByDynamic(object updateDynamicObject)
  566. {
  567. return ScopedContext.UpdateableByDynamic(updateDynamicObject);
  568. }
  569. public IUpdateable<T> Updateable<T>() where T : class, new()
  570. {
  571. return ScopedContext.Updateable<T>();
  572. }
  573. public IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
  574. {
  575. return ScopedContext.Updateable<T>(columnDictionary);
  576. }
  577. public IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
  578. {
  579. return ScopedContext.Updateable<T>((object)updateDynamicObject);
  580. }
  581. public IUpdateable<T> Updateable<T>(Expression<Func<T, bool>> columns) where T : class, new()
  582. {
  583. return ScopedContext.Updateable(columns);
  584. }
  585. public IUpdateable<T> Updateable<T>(Expression<Func<T, T>> columns) where T : class, new()
  586. {
  587. return ScopedContext.Updateable(columns);
  588. }
  589. public IUpdateable<T> Updateable<T>(List<T> UpdateObjs) where T : class, new()
  590. {
  591. return ScopedContext.Updateable(UpdateObjs);
  592. }
  593. public IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new()
  594. {
  595. return ScopedContext.Updateable(UpdateObj);
  596. }
  597. public IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
  598. {
  599. return ScopedContext.Updateable(UpdateObjs);
  600. }
  601. public SplitTableContext SplitHelper<T>() where T : class, new()
  602. {
  603. return ScopedContext.SplitHelper<T>();
  604. }
  605. public SplitTableContext SplitHelper(Type entityType)
  606. {
  607. return ScopedContext.SplitHelper(entityType);
  608. }
  609. public SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new()
  610. {
  611. return ScopedContext.SplitHelper(data);
  612. }
  613. public SplitTableContextResult<T> SplitHelper<T>(List<T> dataList) where T : class, new()
  614. {
  615. return ScopedContext.SplitHelper(dataList);
  616. }
  617. public SqlSugarTransaction UseTran()
  618. {
  619. return ScopedContext.UseTran();
  620. }
  621. public DbResult<bool> UseTran(Action action, Action<Exception> errorCallBack = null)
  622. {
  623. return ScopedContext.UseTran(action,errorCallBack);
  624. }
  625. public DbResult<T> UseTran<T>(Func<T> action, Action<Exception> errorCallBack = null)
  626. {
  627. return ScopedContext.UseTran(action,errorCallBack);
  628. }
  629. public Task<DbResult<bool>> UseTranAsync(Func<Task> action, Action<Exception> errorCallBack = null)
  630. {
  631. return ScopedContext.UseTranAsync(action, errorCallBack);
  632. }
  633. public Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null)
  634. {
  635. return ScopedContext.UseTranAsync(action, errorCallBack);
  636. }
  637. public bool IsAnyConnection(object configId)
  638. {
  639. return ScopedContext.IsAnyConnection(configId);
  640. }
  641. public IFastest<T> Fastest<T>() where T : class, new()
  642. {
  643. return ScopedContext.Fastest<T>();
  644. }
  645. public void ThenMapper<T>(IEnumerable<T> list, Action<T> action)
  646. {
  647. ScopedContext.ThenMapper(list, action);
  648. }
  649. public Task ThenMapperAsync<T>(IEnumerable<T> list, Func<T, Task> action)
  650. {
  651. return ScopedContext.ThenMapperAsync(list, action);
  652. }
  653. public ISugarQueryable<T> QueryableWithAttr<T>()
  654. {
  655. return ScopedContext.QueryableWithAttr<T>();
  656. }
  657. public IInsertable<T> InsertableWithAttr<T>(T insertObj) where T : class, new()
  658. {
  659. return ScopedContext.InsertableWithAttr<T>(insertObj);
  660. }
  661. public IInsertable<T> InsertableWithAttr<T>(List<T> insertObjs) where T : class, new()
  662. {
  663. return ScopedContext.InsertableWithAttr<T>(insertObjs);
  664. }
  665. public IUpdateable<T> UpdateableWithAttr<T>(T updateObj) where T : class, new()
  666. {
  667. return ScopedContext.UpdateableWithAttr<T>(updateObj);
  668. }
  669. public IUpdateable<T> UpdateableWithAttr<T>() where T : class, new()
  670. {
  671. return ScopedContext.UpdateableWithAttr<T>();
  672. }
  673. public IUpdateable<T> UpdateableWithAttr<T>(List<T> updateObjs) where T : class, new()
  674. {
  675. return ScopedContext.UpdateableWithAttr<T>(updateObjs);
  676. }
  677. public IDeleteable<T> DeleteableWithAttr<T>(T deleteObj) where T : class, new()
  678. {
  679. return ScopedContext.DeleteableWithAttr<T>(deleteObj);
  680. }
  681. public IDeleteable<T> DeleteableWithAttr<T>() where T : class, new()
  682. {
  683. return ScopedContext.DeleteableWithAttr<T>();
  684. }
  685. public IDeleteable<T> DeleteableWithAttr<T>(List<T> deleteObjs) where T : class, new()
  686. {
  687. return ScopedContext.DeleteableWithAttr<T>(deleteObjs);
  688. }
  689. public InsertNavTaskInit<T, T> InsertNav<T>(T data) where T : class, new()
  690. {
  691. return ScopedContext.InsertNav(data);
  692. }
  693. public InsertNavTaskInit<T, T> InsertNav<T>(List<T> datas) where T : class, new()
  694. {
  695. return ScopedContext.InsertNav(datas);
  696. }
  697. public InsertNavTaskInit<T, T> InsertNav<T>(T data, InsertNavRootOptions rootOptions) where T : class, new()
  698. {
  699. return ScopedContext.InsertNav(data, rootOptions);
  700. }
  701. public InsertNavTaskInit<T, T> InsertNav<T>(List<T> datas, InsertNavRootOptions rootOptions) where T : class, new()
  702. {
  703. return ScopedContext.InsertNav(datas, rootOptions);
  704. }
  705. public DeleteNavTaskInit<T, T> DeleteNav<T>(T data) where T : class, new()
  706. {
  707. return ScopedContext.DeleteNav(data);
  708. }
  709. public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas) where T : class, new()
  710. {
  711. return ScopedContext.DeleteNav(datas);
  712. }
  713. public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression) where T : class, new()
  714. {
  715. return ScopedContext.DeleteNav(whereExpression);
  716. }
  717. public DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new()
  718. {
  719. return ScopedContext.DeleteNav(data, options);
  720. }
  721. public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new()
  722. {
  723. return ScopedContext.DeleteNav(datas, options);
  724. }
  725. public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new()
  726. {
  727. return ScopedContext.DeleteNav(whereExpression, options);
  728. }
  729. public UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new()
  730. {
  731. return ScopedContext.UpdateNav(data);
  732. }
  733. public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas) where T : class, new()
  734. {
  735. return ScopedContext.UpdateNav(datas);
  736. }
  737. public UpdateNavTaskInit<T, T> UpdateNav<T>(T data,UpdateNavRootOptions rootOptions) where T : class, new()
  738. {
  739. return ScopedContext.UpdateNav(data, rootOptions);
  740. }
  741. public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new()
  742. {
  743. return ScopedContext.UpdateNav(datas, rootOptions);
  744. }
  745. public SqlSugarClient CopyNew()
  746. {
  747. var result= new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));
  748. result.QueryFilter = this.QueryFilter;
  749. if (this.ScopedContext._AllClients != null)
  750. {
  751. foreach (var item in this.ScopedContext._AllClients)
  752. {
  753. if (!result.IsAnyConnection(item.ConnectionConfig.ConfigId))
  754. {
  755. result.AddConnection(UtilMethods.CopyConfig(item.ConnectionConfig));
  756. }
  757. }
  758. }
  759. return result;
  760. }
  761. public DynamicBuilder DynamicBuilder()
  762. {
  763. return ScopedContext.DynamicBuilder();
  764. }
  765. public void Tracking<T>(T data) where T : class, new()
  766. {
  767. ScopedContext.Tracking(data);
  768. }
  769. public void Tracking<T>(List<T> datas) where T : class, new()
  770. {
  771. ScopedContext.Tracking(datas);
  772. }
  773. public void RemoveConnection(dynamic configId)
  774. {
  775. ScopedContext.RemoveConnection(configId);
  776. }
  777. public Task<SugarAsyncLock> AsyncLock(int timeOutSeconds=30)
  778. {
  779. return ScopedContext.AsyncLock(timeOutSeconds);
  780. }
  781. public QueryMethodInfo QueryableByObject(Type entityType)
  782. {
  783. return ScopedContext.QueryableByObject(entityType);
  784. }
  785. public QueryMethodInfo QueryableByObject(Type entityType, string shortName)
  786. {
  787. return ScopedContext.QueryableByObject(entityType, shortName);
  788. }
  789. public GridSaveProvider<T> GridSave<T>(List<T> oldList, List<T> saveList) where T : class, new()
  790. {
  791. return ScopedContext.GridSave(oldList, saveList);
  792. }
  793. public GridSaveProvider<T> GridSave<T>(List<T> saveList) where T : class, new()
  794. {
  795. return ScopedContext.GridSave(saveList);
  796. }
  797. public void ClearTracking()
  798. {
  799. ScopedContext.ClearTracking();
  800. }
  801. }
  802. }