Browse Source

替换测试一下链接关闭现象

zhangkun 5 years ago
parent
commit
60935b95d2
1 changed files with 40 additions and 40 deletions
  1. 40 40
      代码/System.Common/Repositories/BaseRepository.cs

+ 40 - 40
代码/System.Common/Repositories/BaseRepository.cs

9
 {
9
 {
10
     public class BaseRepository<T> : BaseContext, IRepository<T> where T : class, new()
10
     public class BaseRepository<T> : BaseContext, IRepository<T> where T : class, new()
11
     {
11
     {
12
-        //public SimpleClient<T> CurrentDb => new SimpleClient<T>(Db);
12
+        public SimpleClient<T> CurrentDB => new SimpleClient<T>(Db);
13
 
13
 
14
         /// <summary>
14
         /// <summary>
15
         /// 获取数量
15
         /// 获取数量
19
         public async Task<int> GetCount(Expression<Func<T, bool>> whereExpression = null)
19
         public async Task<int> GetCount(Expression<Func<T, bool>> whereExpression = null)
20
         {
20
         {
21
             if (whereExpression != null)
21
             if (whereExpression != null)
22
-                return await Db.Queryable<T>().With(SqlWith.NoLock).CountAsync(whereExpression);
22
+                return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).CountAsync(whereExpression);
23
             else
23
             else
24
-                return await Db.Queryable<T>().With(SqlWith.NoLock).CountAsync();
24
+                return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).CountAsync();
25
         }
25
         }
26
 
26
 
27
         /// <summary>
27
         /// <summary>
30
         /// <returns></returns>
30
         /// <returns></returns>
31
         public async Task<List<T>> GetList()
31
         public async Task<List<T>> GetList()
32
         {
32
         {
33
-            return await Db.Queryable<T>().With(SqlWith.NoLock).ToListAsync();
34
-            //return CurrentDb.GetList();
33
+            return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).ToListAsync();
34
+            //return CurrentCurrentDB.GetList();
35
         }
35
         }
36
         public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression)
36
         public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression)
37
         {
37
         {
38
-            return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToListAsync();
38
+            return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToListAsync();
39
         }
39
         }
40
 
40
 
41
         public async Task<List<T>> GetListALL(List<IConditionalModel> conModels, string orderby)
41
         public async Task<List<T>> GetListALL(List<IConditionalModel> conModels, string orderby)
42
         {
42
         {
43
-            return await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToListAsync();
43
+            return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToListAsync();
44
         }
44
         }
45
 
45
 
46
         public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType ordertype = OrderByType.Asc)
46
         public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType ordertype = OrderByType.Asc)
47
         {
47
         {
48
-            return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderExpression, ordertype).ToListAsync();
48
+            return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderExpression, ordertype).ToListAsync();
49
         }
49
         }
50
 
50
 
51
         /// <summary>
51
         /// <summary>
56
         /// <returns></returns>
56
         /// <returns></returns>
57
         public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel, string orderby)
57
         public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel, string orderby)
58
         {
58
         {
59
-            var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
59
+            var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
60
             PageData<T> pd = new PageData<T>();
60
             PageData<T> pd = new PageData<T>();
61
             pd.Rows = list;
61
             pd.Rows = list;
62
             pd.Totals = pagemodel.PageCount;
62
             pd.Totals = pagemodel.PageCount;
63
-            return pd;// CurrentDb.GetPageList(conModels, pagemodel);
63
+            return pd;// CurrentCurrentDB.GetPageList(conModels, pagemodel);
64
         }
64
         }
65
 
65
 
66
         public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel)
66
         public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel)
67
         {
67
         {
68
-            var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
68
+            var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
69
             PageData<T> pd = new PageData<T>();
69
             PageData<T> pd = new PageData<T>();
70
             pd.Rows = list;
70
             pd.Rows = list;
71
             pd.Totals = pagemodel.PageCount;
71
             pd.Totals = pagemodel.PageCount;
72
-            return pd;// CurrentDb.GetPageList(conModels, pagemodel);
72
+            return pd;// CurrentCurrentDB.GetPageList(conModels, pagemodel);
73
         }
73
         }
74
 
74
 
75
         public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel)
75
         public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel)
76
         {
76
         {
77
-            var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
77
+            var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
78
             PageData<T> pd = new PageData<T>();
78
             PageData<T> pd = new PageData<T>();
79
             pd.Rows = list;
79
             pd.Rows = list;
80
             pd.Totals = pagemodel.PageCount;
80
             pd.Totals = pagemodel.PageCount;
81
-            return pd;// CurrentDb.GetPageList(conModels, pagemodel);
81
+            return pd;// CurrentCurrentDB.GetPageList(conModels, pagemodel);
82
         }
82
         }
83
 
83
 
84
         public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel, string orderby)
84
         public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel, string orderby)
85
         {
85
         {
86
-            var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
86
+            var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
87
             PageData<T> pd = new PageData<T>();
87
             PageData<T> pd = new PageData<T>();
88
             pd.Rows = list;
88
             pd.Rows = list;
89
             pd.Totals = pagemodel.PageCount;
89
             pd.Totals = pagemodel.PageCount;
90
-            return pd;// CurrentDb.GetPageList(conModels, pagemodel);
90
+            return pd;// CurrentCurrentDB.GetPageList(conModels, pagemodel);
91
         }
91
         }
92
 
92
 
93
         public async Task<T> GetSingle(Expression<Func<T, bool>> whereExpression)
93
         public async Task<T> GetSingle(Expression<Func<T, bool>> whereExpression)
94
         {
94
         {
95
-            return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
96
-            //return CurrentDb.GetSingle(whereExpression);
95
+            return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
96
+            //return CurrentCurrentDB.GetSingle(whereExpression);
97
         }
97
         }
98
 
98
 
99
         /// <summary>
99
         /// <summary>
103
         /// <returns></returns>
103
         /// <returns></returns>
104
         public async Task<int> Add(T obj)
104
         public async Task<int> Add(T obj)
105
         {
105
         {
106
-            return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
107
-            //return CurrentDb.InsertReturnIdentity(obj);
106
+            return await CurrentDB.AsSugarClient().Insertable<T>(obj).ExecuteReturnIdentityAsync();
107
+            //return CurrentCurrentDB.InsertReturnIdentity(obj);
108
         }
108
         }
109
 
109
 
110
         /// <summary>
110
         /// <summary>
114
         /// <returns></returns>
114
         /// <returns></returns>
115
         public async Task<bool> AddReturnCount(T obj)
115
         public async Task<bool> AddReturnCount(T obj)
116
         {
116
         {
117
-            int res = await Db.Insertable<T>(obj).ExecuteCommandAsync();
117
+            int res = await CurrentDB.AsSugarClient().Insertable<T>(obj).ExecuteCommandAsync();
118
             return res > 0;
118
             return res > 0;
119
         }
119
         }
120
 
120
 
126
         /// <returns></returns>
126
         /// <returns></returns>
127
         public async Task<int> AddIgnore(T obj, Expression<Func<T, object>> IgnoreColumns)
127
         public async Task<int> AddIgnore(T obj, Expression<Func<T, object>> IgnoreColumns)
128
         {
128
         {
129
-            return await Db.Insertable<T>(obj).IgnoreColumns(IgnoreColumns).ExecuteReturnIdentityAsync();
130
-            //return CurrentDb.InsertReturnIdentity(obj);
129
+            return await CurrentDB.AsSugarClient().Insertable<T>(obj).IgnoreColumns(IgnoreColumns).ExecuteReturnIdentityAsync();
130
+            //return CurrentCurrentDB.InsertReturnIdentity(obj);
131
         }
131
         }
132
 
132
 
133
         /// <summary>
133
         /// <summary>
138
         /// <returns></returns>
138
         /// <returns></returns>
139
         public async Task<int> AddStrong(T obj, bool isStrong = false)
139
         public async Task<int> AddStrong(T obj, bool isStrong = false)
140
         {
140
         {
141
-            return await Db.Insertable<T>(obj).IgnoreColumns(true, isStrong).ExecuteReturnIdentityAsync();
142
-            //return CurrentDb.InsertReturnIdentity(obj);
141
+            return await CurrentDB.AsSugarClient().Insertable<T>(obj).IgnoreColumns(true, isStrong).ExecuteReturnIdentityAsync();
142
+            //return CurrentCurrentDB.InsertReturnIdentity(obj);
143
         }
143
         }
144
         /// <summary>
144
         /// <summary>
145
         /// 批量添加
145
         /// 批量添加
148
         /// <returns></returns>
148
         /// <returns></returns>
149
         public async Task<bool> AddMany(List<T> objlist)
149
         public async Task<bool> AddMany(List<T> objlist)
150
         {
150
         {
151
-            var res = await Db.Insertable<T>(objlist).ExecuteCommandAsync();
151
+            var res = await CurrentDB.AsSugarClient().Insertable<T>(objlist).ExecuteCommandAsync();
152
             return res > 0;
152
             return res > 0;
153
         }
153
         }
154
 
154
 
158
         /// <returns></returns>
158
         /// <returns></returns>
159
         public async Task<bool> Delete(Expression<Func<T, bool>> whereExpression)
159
         public async Task<bool> Delete(Expression<Func<T, bool>> whereExpression)
160
         {
160
         {
161
-            return await Db.Deleteable<T>(whereExpression).ExecuteCommandHasChangeAsync();
162
-            //return CurrentDb.Delete(whereExpression);
161
+            return await CurrentDB.AsSugarClient().Deleteable<T>(whereExpression).ExecuteCommandHasChangeAsync();
162
+            //return CurrentCurrentDB.Delete(whereExpression);
163
         }
163
         }
164
 
164
 
165
         /// <summary>
165
         /// <summary>
169
         /// <returns></returns>
169
         /// <returns></returns>
170
         public async Task<bool> Update(T obj)
170
         public async Task<bool> Update(T obj)
171
         {
171
         {
172
-            return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
173
-            //return CurrentDb.Update(obj);
172
+            return await CurrentDB.AsSugarClient().Updateable<T>(obj).ExecuteCommandHasChangeAsync();
173
+            //return CurrentCurrentDB.Update(obj);
174
         }
174
         }
175
         /// <summary>
175
         /// <summary>
176
         /// 条件更新
176
         /// 条件更新
179
         /// <returns></returns>
179
         /// <returns></returns>
180
         public async Task<bool> Update(Expression<Func<T, T>> UpdateColumnsExpression, Expression<Func<T, bool>> whereExpression)
180
         public async Task<bool> Update(Expression<Func<T, T>> UpdateColumnsExpression, Expression<Func<T, bool>> whereExpression)
181
         {
181
         {
182
-            return await Db.Updateable<T>().SetColumns(UpdateColumnsExpression).Where(whereExpression).ExecuteCommandHasChangeAsync();
183
-            //return CurrentDb.Update(obj);
182
+            return await CurrentDB.AsSugarClient().Updateable<T>().SetColumns(UpdateColumnsExpression).Where(whereExpression).ExecuteCommandHasChangeAsync();
183
+            //return CurrentCurrentDB.Update(obj);
184
         }
184
         }
185
         /// <summary>
185
         /// <summary>
186
         /// 批量整条更新
186
         /// 批量整条更新
189
         /// <returns></returns>
189
         /// <returns></returns>
190
         public async Task<bool> UpdateList(List<T> obj)
190
         public async Task<bool> UpdateList(List<T> obj)
191
         {
191
         {
192
-            return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
193
-            //return CurrentDb.Update(obj);
192
+            return await CurrentDB.AsSugarClient().Updateable<T>(obj).ExecuteCommandHasChangeAsync();
193
+            //return CurrentCurrentDB.Update(obj);
194
         }
194
         }
195
 
195
 
196
         public Data.DataTable GetTableSugar(string sql, SugarParameter[] sugarParameter = null)
196
         public Data.DataTable GetTableSugar(string sql, SugarParameter[] sugarParameter = null)
197
         {
197
         {
198
             if (sugarParameter == null)
198
             if (sugarParameter == null)
199
-            { return Db.Ado.GetDataTable(sql); }
199
+            { return CurrentDB.AsSugarClient().Ado.GetDataTable(sql); }
200
             else
200
             else
201
-            { return Db.Ado.GetDataTable(sql, sugarParameter); }
201
+            { return CurrentDB.AsSugarClient().Ado.GetDataTable(sql, sugarParameter); }
202
         }
202
         }
203
 
203
 
204
         public int ExecuteCommandSugar(string sql,SugarParameter[] sugarParameter=null)
204
         public int ExecuteCommandSugar(string sql,SugarParameter[] sugarParameter=null)
205
         {
205
         {
206
             if (sugarParameter == null)
206
             if (sugarParameter == null)
207
-            { return Db.Ado.ExecuteCommand(sql); }
207
+            { return CurrentDB.AsSugarClient().Ado.ExecuteCommand(sql); }
208
             else
208
             else
209
-            { return Db.Ado.ExecuteCommand(sql, sugarParameter); }
209
+            { return CurrentDB.AsSugarClient().Ado.ExecuteCommand(sql, sugarParameter); }
210
         }
210
         }
211
 
211
 
212
         /// <summary>
212
         /// <summary>
217
         [Obsolete]
217
         [Obsolete]
218
         public async Task<bool> UpdateListToColumns(List<T> obj, Expression<Func<T, object>> objColumns)
218
         public async Task<bool> UpdateListToColumns(List<T> obj, Expression<Func<T, object>> objColumns)
219
         {
219
         {
220
-            return await Db.Updateable<T>(obj).UpdateColumns(objColumns).ExecuteCommandHasChangeAsync();
221
-            //return CurrentDb.Update(obj);
220
+            return await CurrentDB.AsSugarClient().Updateable<T>(obj).UpdateColumns(objColumns).ExecuteCommandHasChangeAsync();
221
+            //return CurrentCurrentDB.Update(obj);
222
         }
222
         }
223
     }
223
     }
224
 }
224
 }