ISqlSugarClient.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Dynamic;
  5. using System.Linq.Expressions;
  6. using System.Reflection;
  7. using System.Threading.Tasks;
  8. namespace SqlSugar
  9. {
  10. public interface ISqlSugarClient : IDisposable
  11. {
  12. MappingTableList MappingTables { get; set; }
  13. MappingColumnList MappingColumns { get; set; }
  14. IgnoreColumnList IgnoreColumns { get; set; }
  15. IgnoreColumnList IgnoreInsertColumns { get; set; }
  16. Dictionary<string, object> TempItems { get; set; }
  17. ConfigQuery ConfigQuery { get; set; }
  18. bool IsSystemTablesConfig { get; }
  19. Guid ContextID { get; set; }
  20. ConnectionConfig CurrentConnectionConfig { get; set; }
  21. IAdo Ado { get; }
  22. AopProvider Aop { get; }
  23. ICodeFirst CodeFirst { get; }
  24. IDbFirst DbFirst { get; }
  25. IDbMaintenance DbMaintenance { get; }
  26. EntityMaintenance EntityMaintenance { get; set; }
  27. QueryFilterProvider QueryFilter { get; set; }
  28. IContextMethods Utilities { get; set; }
  29. SugarActionType SugarActionType { get; set; }
  30. #region Deleteable
  31. DeleteMethodInfo DeleteableByObject(object singleEntityObjectOrListObject);
  32. IDeleteable<T> Deleteable<T>() where T : class, new();
  33. IDeleteable<T> Deleteable<T>(dynamic primaryKeyValue) where T : class, new();
  34. IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new();
  35. IDeleteable<T> Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new();
  36. IDeleteable<T> Deleteable<T>(List<dynamic> pkValue) where T : class, new();
  37. IDeleteable<T> Deleteable<T>(List<T> deleteObjs) where T : class, new();
  38. IDeleteable<T> Deleteable<T>(T deleteObj) where T : class, new();
  39. #endregion
  40. #region Other methods
  41. Task<SugarAsyncLock> AsyncLock(int timeOutSeconds = 30);
  42. DynamicBuilder DynamicBuilder();
  43. void ClearTracking();
  44. void Tracking<T>(T data) where T : class, new();
  45. void Tracking<T>(List<T> data) where T : class, new();
  46. SqlSugarClient CopyNew();
  47. T CreateContext<T>(bool isTran=true) where T : SugarUnitOfWork, new();
  48. SugarUnitOfWork CreateContext(bool isTran = true);
  49. SplitTableContext SplitHelper(Type entityType);
  50. SplitTableContext SplitHelper<T>() where T : class, new();
  51. SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new();
  52. SplitTableContextResult<T> SplitHelper<T>(List<T> data) where T : class, new();
  53. DateTime GetDate();
  54. //SimpleClient GetSimpleClient();
  55. SimpleClient<T> GetSimpleClient<T>() where T : class, new();
  56. RepositoryType GetRepository<RepositoryType>() where RepositoryType : ISugarRepository, new();
  57. void InitMappingInfo(Type type);
  58. void InitMappingInfo<T>();
  59. void Open();
  60. void Close();
  61. ITenant AsTenant();
  62. #endregion
  63. #region Insertable
  64. IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new();
  65. IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new();
  66. IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new();
  67. IInsertable<T> Insertable<T>(T insertObj) where T : class, new();
  68. IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new();
  69. InsertMethodInfo InsertableByObject(object singleEntityObjectOrListObject);
  70. IInsertable<Dictionary<string, object>> InsertableByDynamic(object insertDynamicObject);
  71. #endregion
  72. #region Queryable
  73. QueryMethodInfo QueryableByObject(Type entityType, string shortName);
  74. QueryMethodInfo QueryableByObject(Type entityType);
  75. ISugarQueryable<T> MasterQueryable<T>();
  76. ISugarQueryable<T> SlaveQueryable<T>();
  77. ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new();
  78. ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
  79. 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();
  80. 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);
  81. 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);
  82. 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();
  83. 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);
  84. 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);
  85. 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();
  86. 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);
  87. 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);
  88. 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();
  89. 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);
  90. 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);
  91. 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();
  92. 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);
  93. 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);
  94. 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();
  95. 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);
  96. 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);
  97. 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();
  98. ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, JoinQueryInfos>> joinExpression);
  99. ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression);
  100. 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();
  101. ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, JoinQueryInfos>> joinExpression);
  102. ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression);
  103. ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpression) where T : class, new();
  104. ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, JoinQueryInfos>> joinExpression);
  105. ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression);
  106. ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, bool>> joinExpression) where T : class, new();
  107. ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, JoinQueryInfos>> joinExpression);
  108. ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression);
  109. ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, bool>> joinExpression) where T : class, new();
  110. ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, JoinQueryInfos>> joinExpression);
  111. ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, object[]>> joinExpression);
  112. ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, Expression<Func<T, T2, bool>> joinExpression)
  113. where T : class, new()
  114. where T2 : class, new();
  115. ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, JoinType joinType, Expression<Func<T, T2, bool>> joinExpression)
  116. where T : class, new()
  117. where T2 : class, new();
  118. ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, ISugarQueryable<T3> joinQueryable3,
  119. JoinType joinType1, Expression<Func<T, T2, T3, bool>> joinExpression1,
  120. JoinType joinType2, Expression<Func<T, T2, T3, bool>> joinExpression2)
  121. where T : class, new()
  122. where T2 : class, new()
  123. where T3 : class, new();
  124. ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, ISugarQueryable<T3> joinQueryable3, ISugarQueryable<T4> joinQueryable4,
  125. JoinType joinType1, Expression<Func<T, T2, T3, T4, bool>> joinExpression1,
  126. JoinType joinType2, Expression<Func<T, T2, T3, T4, bool>> joinExpression2,
  127. JoinType joinType3, Expression<Func<T, T2, T3, T4, bool>> joinExpression4)
  128. where T : class, new()
  129. where T2 : class, new()
  130. where T3 : class, new()
  131. where T4 : class, new();
  132. ISugarQueryable<T> Queryable<T>();
  133. ISugarQueryable<T> Queryable<T>(ISugarQueryable<T> queryable);
  134. ISugarQueryable<T> Queryable<T>(ISugarQueryable<T> queryable,string shortName);
  135. ISugarQueryable<T> Queryable<T>(string shortName);
  136. #endregion
  137. #region Saveable
  138. GridSaveProvider<T> GridSave<T>(List<T> saveList) where T : class, new();
  139. GridSaveProvider<T> GridSave<T>(List<T> oldList,List<T> saveList) where T : class, new();
  140. IStorageable<T> Storageable<T>(T[] dataList) where T : class, new();
  141. IStorageable<T> Storageable<T>(IList<T> dataList) where T : class, new();
  142. StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName);
  143. StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName);
  144. IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new();
  145. IStorageable<T> Storageable<T>(T data) where T : class, new();
  146. StorageableDataTable Storageable(DataTable data);
  147. [Obsolete("use Storageable")]
  148. ISaveable<T> Saveable<T>(List<T> saveObjects) where T : class, new();
  149. [Obsolete("use Storageable")]
  150. ISaveable<T> Saveable<T>(T saveObject) where T : class, new();
  151. StorageableMethodInfo StorageableByObject(object singleEntityObjectOrListObject);
  152. #endregion
  153. #region Queue
  154. QueueList Queues { get; set; }
  155. void AddQueue(string sql, object parsmeters = null);
  156. void AddQueue(string sql, List<SugarParameter> parsmeters);
  157. void AddQueue(string sql, SugarParameter parsmeter);
  158. int SaveQueues(bool isTran = true);
  159. 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);
  160. Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>> SaveQueues<T, T2, T3, T4, T5, T6>(bool isTran = true);
  161. Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>> SaveQueues<T, T2, T3, T4, T5>(bool isTran = true);
  162. Tuple<List<T>, List<T2>, List<T3>, List<T4>> SaveQueues<T, T2, T3, T4>(bool isTran = true);
  163. Tuple<List<T>, List<T2>, List<T3>> SaveQueues<T, T2, T3>(bool isTran = true);
  164. Tuple<List<T>, List<T2>> SaveQueues<T, T2>(bool isTran = true);
  165. List<T> SaveQueues<T>(bool isTran = true);
  166. Task<int> SaveQueuesAsync(bool isTran = true);
  167. 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);
  168. Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>>> SaveQueuesAsync<T, T2, T3, T4, T5, T6>(bool isTran = true);
  169. Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>>> SaveQueuesAsync<T, T2, T3, T4, T5>(bool isTran = true);
  170. Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>>> SaveQueuesAsync<T, T2, T3, T4>(bool isTran = true);
  171. Task<Tuple<List<T>, List<T2>, List<T3>>> SaveQueuesAsync<T, T2, T3>(bool isTran = true);
  172. Task<Tuple<List<T>, List<T2>>> SaveQueuesAsync<T, T2>(bool isTran = true);
  173. Task<List<T>> SaveQueuesAsync<T>(bool isTran = true);
  174. #endregion
  175. #region Union
  176. ISugarQueryable<T> Union<T>(List<ISugarQueryable<T>> queryables) where T : class, new();
  177. ISugarQueryable<T> Union<T>(params ISugarQueryable<T>[] queryables) where T : class, new();
  178. ISugarQueryable<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new();
  179. ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new();
  180. #endregion
  181. #region Updateable
  182. UpdateMethodInfo UpdateableByObject(object singleEntityObjectOrListObject);
  183. UpdateExpressionMethodInfo UpdateableByObject(Type entityType);
  184. IUpdateable<T> Updateable<T>() where T : class, new();
  185. IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new();
  186. IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new();
  187. IUpdateable<T> Updateable<T>(Expression<Func<T, bool>> columns) where T : class, new();
  188. IUpdateable<T> Updateable<T>(Expression<Func<T, T>> columns) where T : class, new();
  189. IUpdateable<T> Updateable<T>(List<T> UpdateObjs) where T : class, new();
  190. IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new();
  191. IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new();
  192. IUpdateable<Dictionary<string, object>> UpdateableByDynamic(object updateDynamicObject);
  193. #endregion
  194. #region Reportable
  195. IReportable<T> Reportable<T>(T data);
  196. IReportable<T> Reportable<T>(List<T> list);
  197. IReportable<T> Reportable<T>(T[] array);
  198. #endregion
  199. #region Cache
  200. SugarCacheProvider DataCache { get; }
  201. #endregion
  202. #region Fastest
  203. IFastest<T> Fastest<T>() where T : class, new();
  204. #endregion
  205. #region ThenMapper
  206. void ThenMapper<T>(IEnumerable<T> list, Action<T> action);
  207. Task ThenMapperAsync<T>(IEnumerable<T> list, Func<T,Task> action);
  208. #endregion
  209. #region Nav CUD
  210. InsertNavTaskInit<T, T> InsertNav<T>(T data) where T : class, new();
  211. InsertNavTaskInit<T, T> InsertNav<T>(List<T> datas) where T : class, new();
  212. InsertNavTaskInit<T, T> InsertNav<T>(T data,InsertNavRootOptions rootOptions) where T : class, new();
  213. InsertNavTaskInit<T, T> InsertNav<T>(List<T> datas, InsertNavRootOptions rootOptions) where T : class, new();
  214. DeleteNavTaskInit<T, T> DeleteNav<T>(T data) where T : class, new();
  215. DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas) where T : class, new();
  216. DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T,bool>> whereExpression) where T : class, new();
  217. DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new();
  218. DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new();
  219. DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new();
  220. UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new ();
  221. UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas) where T : class, new ();
  222. UpdateNavTaskInit<T, T> UpdateNav<T>(T data,UpdateNavRootOptions rootOptions) where T : class, new();
  223. UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new();
  224. #endregion
  225. }
  226. }