|
|
@@ -19,9 +19,10 @@ namespace System.Common
|
|
19
|
19
|
public async Task<int> GetCount(Expression<Func<T, bool>> whereExpression = null)
|
|
20
|
20
|
{
|
|
21
|
21
|
if (whereExpression != null)
|
|
22
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).CountAsync(whereExpression);
|
|
|
22
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).CountAsync(whereExpression);
|
|
23
|
23
|
else
|
|
24
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).CountAsync();
|
|
|
24
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).CountAsync();
|
|
|
25
|
+
|
|
25
|
26
|
}
|
|
26
|
27
|
|
|
27
|
28
|
/// <summary>
|
|
|
@@ -30,22 +31,23 @@ namespace System.Common
|
|
30
|
31
|
/// <returns></returns>
|
|
31
|
32
|
public async Task<List<T>> GetList()
|
|
32
|
33
|
{
|
|
33
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).ToListAsync();
|
|
|
34
|
+
|
|
|
35
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).ToListAsync();
|
|
34
|
36
|
//return CurrentCurrentDB.GetList();
|
|
35
|
37
|
}
|
|
36
|
38
|
public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression)
|
|
37
|
39
|
{
|
|
38
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToListAsync();
|
|
|
40
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToListAsync();
|
|
39
|
41
|
}
|
|
40
|
42
|
|
|
41
|
43
|
public async Task<List<T>> GetListALL(List<IConditionalModel> conModels, string orderby)
|
|
42
|
44
|
{
|
|
43
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToListAsync();
|
|
|
45
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToListAsync();
|
|
44
|
46
|
}
|
|
45
|
47
|
|
|
46
|
48
|
public async Task<List<T>> GetListALL(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType ordertype = OrderByType.Asc)
|
|
47
|
49
|
{
|
|
48
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderExpression, ordertype).ToListAsync();
|
|
|
50
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderExpression, ordertype).ToListAsync();
|
|
49
|
51
|
}
|
|
50
|
52
|
|
|
51
|
53
|
/// <summary>
|
|
|
@@ -56,7 +58,7 @@ namespace System.Common
|
|
56
|
58
|
/// <returns></returns>
|
|
57
|
59
|
public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel, string orderby)
|
|
58
|
60
|
{
|
|
59
|
|
- var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
|
61
|
+ var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
60
|
62
|
PageData<T> pd = new PageData<T>();
|
|
61
|
63
|
pd.Rows = list;
|
|
62
|
64
|
pd.Totals = pagemodel.PageCount;
|
|
|
@@ -65,7 +67,7 @@ namespace System.Common
|
|
65
|
67
|
|
|
66
|
68
|
public async Task<PageData<T>> GetListByPage(List<IConditionalModel> conModels, MyPageModel pagemodel)
|
|
67
|
69
|
{
|
|
68
|
|
- var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(conModels).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
|
70
|
+ var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(conModels).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
69
|
71
|
PageData<T> pd = new PageData<T>();
|
|
70
|
72
|
pd.Rows = list;
|
|
71
|
73
|
pd.Totals = pagemodel.PageCount;
|
|
|
@@ -74,7 +76,7 @@ namespace System.Common
|
|
74
|
76
|
|
|
75
|
77
|
public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel)
|
|
76
|
78
|
{
|
|
77
|
|
- var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
|
79
|
+ var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
78
|
80
|
PageData<T> pd = new PageData<T>();
|
|
79
|
81
|
pd.Rows = list;
|
|
80
|
82
|
pd.Totals = pagemodel.PageCount;
|
|
|
@@ -83,17 +85,20 @@ namespace System.Common
|
|
83
|
85
|
|
|
84
|
86
|
public async Task<PageData<T>> GetListByPage(Expression<Func<T, bool>> whereExpression, MyPageModel pagemodel, string orderby)
|
|
85
|
87
|
{
|
|
86
|
|
- var list = await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
|
88
|
+ var list = await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
|
|
87
|
89
|
PageData<T> pd = new PageData<T>();
|
|
88
|
90
|
pd.Rows = list;
|
|
89
|
91
|
pd.Totals = pagemodel.PageCount;
|
|
90
|
92
|
return pd;// CurrentCurrentDB.GetPageList(conModels, pagemodel);
|
|
|
93
|
+
|
|
91
|
94
|
}
|
|
92
|
95
|
|
|
93
|
96
|
public async Task<T> GetSingle(Expression<Func<T, bool>> whereExpression)
|
|
94
|
97
|
{
|
|
95
|
|
- return await CurrentDB.AsSugarClient().Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
|
|
|
98
|
+
|
|
|
99
|
+ return await Db.Queryable<T>().With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
|
|
96
|
100
|
//return CurrentCurrentDB.GetSingle(whereExpression);
|
|
|
101
|
+
|
|
97
|
102
|
}
|
|
98
|
103
|
|
|
99
|
104
|
/// <summary>
|
|
|
@@ -103,7 +108,7 @@ namespace System.Common
|
|
103
|
108
|
/// <returns></returns>
|
|
104
|
109
|
public async Task<int> Add(T obj)
|
|
105
|
110
|
{
|
|
106
|
|
- return await CurrentDB.AsSugarClient().Insertable<T>(obj).ExecuteReturnIdentityAsync();
|
|
|
111
|
+ return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
|
|
107
|
112
|
//return CurrentCurrentDB.InsertReturnIdentity(obj);
|
|
108
|
113
|
}
|
|
109
|
114
|
|
|
|
@@ -114,7 +119,7 @@ namespace System.Common
|
|
114
|
119
|
/// <returns></returns>
|
|
115
|
120
|
public async Task<bool> AddReturnCount(T obj)
|
|
116
|
121
|
{
|
|
117
|
|
- int res = await CurrentDB.AsSugarClient().Insertable<T>(obj).ExecuteCommandAsync();
|
|
|
122
|
+ int res = await Db.Insertable<T>(obj).ExecuteCommandAsync();
|
|
118
|
123
|
return res > 0;
|
|
119
|
124
|
}
|
|
120
|
125
|
|
|
|
@@ -126,7 +131,7 @@ namespace System.Common
|
|
126
|
131
|
/// <returns></returns>
|
|
127
|
132
|
public async Task<int> AddIgnore(T obj, Expression<Func<T, object>> IgnoreColumns)
|
|
128
|
133
|
{
|
|
129
|
|
- return await CurrentDB.AsSugarClient().Insertable<T>(obj).IgnoreColumns(IgnoreColumns).ExecuteReturnIdentityAsync();
|
|
|
134
|
+ return await Db.Insertable<T>(obj).IgnoreColumns(IgnoreColumns).ExecuteReturnIdentityAsync();
|
|
130
|
135
|
//return CurrentCurrentDB.InsertReturnIdentity(obj);
|
|
131
|
136
|
}
|
|
132
|
137
|
|
|
|
@@ -138,7 +143,7 @@ namespace System.Common
|
|
138
|
143
|
/// <returns></returns>
|
|
139
|
144
|
public async Task<int> AddStrong(T obj, bool isStrong = false)
|
|
140
|
145
|
{
|
|
141
|
|
- return await CurrentDB.AsSugarClient().Insertable<T>(obj).IgnoreColumns(true, isStrong).ExecuteReturnIdentityAsync();
|
|
|
146
|
+ return await Db.Insertable<T>(obj).IgnoreColumns(true, isStrong).ExecuteReturnIdentityAsync();
|
|
142
|
147
|
//return CurrentCurrentDB.InsertReturnIdentity(obj);
|
|
143
|
148
|
}
|
|
144
|
149
|
/// <summary>
|
|
|
@@ -148,7 +153,7 @@ namespace System.Common
|
|
148
|
153
|
/// <returns></returns>
|
|
149
|
154
|
public async Task<bool> AddMany(List<T> objlist)
|
|
150
|
155
|
{
|
|
151
|
|
- var res = await CurrentDB.AsSugarClient().Insertable<T>(objlist).ExecuteCommandAsync();
|
|
|
156
|
+ var res = await Db.Insertable<T>(objlist).ExecuteCommandAsync();
|
|
152
|
157
|
return res > 0;
|
|
153
|
158
|
}
|
|
154
|
159
|
|
|
|
@@ -158,7 +163,7 @@ namespace System.Common
|
|
158
|
163
|
/// <returns></returns>
|
|
159
|
164
|
public async Task<bool> Delete(Expression<Func<T, bool>> whereExpression)
|
|
160
|
165
|
{
|
|
161
|
|
- return await CurrentDB.AsSugarClient().Deleteable<T>(whereExpression).ExecuteCommandHasChangeAsync();
|
|
|
166
|
+ return await Db.Deleteable<T>(whereExpression).ExecuteCommandHasChangeAsync();
|
|
162
|
167
|
//return CurrentCurrentDB.Delete(whereExpression);
|
|
163
|
168
|
}
|
|
164
|
169
|
|
|
|
@@ -169,7 +174,7 @@ namespace System.Common
|
|
169
|
174
|
/// <returns></returns>
|
|
170
|
175
|
public async Task<bool> Update(T obj)
|
|
171
|
176
|
{
|
|
172
|
|
- return await CurrentDB.AsSugarClient().Updateable<T>(obj).ExecuteCommandHasChangeAsync();
|
|
|
177
|
+ return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
|
|
173
|
178
|
//return CurrentCurrentDB.Update(obj);
|
|
174
|
179
|
}
|
|
175
|
180
|
/// <summary>
|
|
|
@@ -179,7 +184,7 @@ namespace System.Common
|
|
179
|
184
|
/// <returns></returns>
|
|
180
|
185
|
public async Task<bool> Update(Expression<Func<T, T>> UpdateColumnsExpression, Expression<Func<T, bool>> whereExpression)
|
|
181
|
186
|
{
|
|
182
|
|
- return await CurrentDB.AsSugarClient().Updateable<T>().SetColumns(UpdateColumnsExpression).Where(whereExpression).ExecuteCommandHasChangeAsync();
|
|
|
187
|
+ return await Db.Updateable<T>().SetColumns(UpdateColumnsExpression).Where(whereExpression).ExecuteCommandHasChangeAsync();
|
|
183
|
188
|
//return CurrentCurrentDB.Update(obj);
|
|
184
|
189
|
}
|
|
185
|
190
|
/// <summary>
|
|
|
@@ -189,24 +194,24 @@ namespace System.Common
|
|
189
|
194
|
/// <returns></returns>
|
|
190
|
195
|
public async Task<bool> UpdateList(List<T> obj)
|
|
191
|
196
|
{
|
|
192
|
|
- return await CurrentDB.AsSugarClient().Updateable<T>(obj).ExecuteCommandHasChangeAsync();
|
|
|
197
|
+ return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
|
|
193
|
198
|
//return CurrentCurrentDB.Update(obj);
|
|
194
|
199
|
}
|
|
195
|
200
|
|
|
196
|
|
- public Data.DataTable GetTableSugar(string sql, SugarParameter[] sugarParameter = null)
|
|
|
201
|
+ public async Task<Data.DataTable> GetTableSugar(string sql, SugarParameter[] sugarParameter = null)
|
|
197
|
202
|
{
|
|
198
|
203
|
if (sugarParameter == null)
|
|
199
|
|
- { return CurrentDB.AsSugarClient().Ado.GetDataTable(sql); }
|
|
|
204
|
+ { return await Db.Ado.GetDataTableAsync(sql); }
|
|
200
|
205
|
else
|
|
201
|
|
- { return CurrentDB.AsSugarClient().Ado.GetDataTable(sql, sugarParameter); }
|
|
|
206
|
+ { return await Db.Ado.GetDataTableAsync(sql, sugarParameter); }
|
|
202
|
207
|
}
|
|
203
|
208
|
|
|
204
|
|
- public int ExecuteCommandSugar(string sql,SugarParameter[] sugarParameter=null)
|
|
|
209
|
+ public async Task<int> ExecuteCommandSugar(string sql, SugarParameter[] sugarParameter = null)
|
|
205
|
210
|
{
|
|
206
|
211
|
if (sugarParameter == null)
|
|
207
|
|
- { return CurrentDB.AsSugarClient().Ado.ExecuteCommand(sql); }
|
|
|
212
|
+ { return await Db.Ado.ExecuteCommandAsync(sql); }
|
|
208
|
213
|
else
|
|
209
|
|
- { return CurrentDB.AsSugarClient().Ado.ExecuteCommand(sql, sugarParameter); }
|
|
|
214
|
+ { return await Db.Ado.ExecuteCommandAsync(sql, sugarParameter); }
|
|
210
|
215
|
}
|
|
211
|
216
|
|
|
212
|
217
|
/// <summary>
|
|
|
@@ -217,8 +222,8 @@ namespace System.Common
|
|
217
|
222
|
[Obsolete]
|
|
218
|
223
|
public async Task<bool> UpdateListToColumns(List<T> obj, Expression<Func<T, object>> objColumns)
|
|
219
|
224
|
{
|
|
220
|
|
- return await CurrentDB.AsSugarClient().Updateable<T>(obj).UpdateColumns(objColumns).ExecuteCommandHasChangeAsync();
|
|
221
|
|
- //return CurrentCurrentDB.Update(obj);
|
|
|
225
|
+ return await Db.Updateable<T>(obj).UpdateColumns(objColumns).ExecuteCommandHasChangeAsync();
|
|
|
226
|
+ //return CurrentCurrentDB.Update(obj);
|
|
222
|
227
|
}
|
|
223
|
228
|
}
|
|
224
|
229
|
}
|