|
@@ -112,6 +112,10 @@ namespace Luticate2.Utils.DataAccess
|
112
|
112
|
var models = objs.Select(GetModelFromTCreate).ToList();
|
113
|
113
|
Table.AddRange(models);
|
114
|
114
|
Db.SaveChanges();
|
|
115
|
+ foreach (var model in models)
|
|
116
|
+ {
|
|
117
|
+ Db.Entry(model).State = EntityState.Detached;
|
|
118
|
+ }
|
115
|
119
|
var dbos = models.Select(GetDboFromModel).ToList();
|
116
|
120
|
var res = returnFunc(dbos);
|
117
|
121
|
return LuResult<T>.Ok(res);
|
|
@@ -153,7 +157,7 @@ namespace Luticate2.Utils.DataAccess
|
153
|
157
|
{
|
154
|
158
|
return Execute(() =>
|
155
|
159
|
{
|
156
|
|
- var model = GetGetQueryable().FirstOrDefault(predicate);
|
|
160
|
+ var model = GetGetQueryable().AsNoTracking().FirstOrDefault(predicate);
|
157
|
161
|
if (model == default(TModel))
|
158
|
162
|
{
|
159
|
163
|
return GetNotFoundResult<TDboRead>();
|
|
@@ -192,7 +196,7 @@ namespace Luticate2.Utils.DataAccess
|
192
|
196
|
{
|
193
|
197
|
ordered = func(ordered);
|
194
|
198
|
}
|
195
|
|
- var data = ordered.Where(predicate).Skip(page * perPage).Take(perPage).Select(GetDboFromModel).ToList();
|
|
199
|
+ var data = ordered.Where(predicate).Skip(page * perPage).Take(perPage).AsNoTracking().Select(GetDboFromModel).ToList();
|
196
|
200
|
var result = new LuPaginatedDbo<TDboRead>
|
197
|
201
|
{
|
198
|
202
|
Count = count,
|
|
@@ -248,7 +252,7 @@ namespace Luticate2.Utils.DataAccess
|
248
|
252
|
}
|
249
|
253
|
}
|
250
|
254
|
|
251
|
|
- var data = ordered.Skip(page * perPage).Take(perPage).Select(GetDboFromModel).ToList();
|
|
255
|
+ var data = ordered.Skip(page * perPage).Take(perPage).AsNoTracking().Select(GetDboFromModel).ToList();
|
252
|
256
|
var result = new LuPaginatedDbo<TDboRead>
|
253
|
257
|
{
|
254
|
258
|
Count = count,
|
|
@@ -276,7 +280,7 @@ namespace Luticate2.Utils.DataAccess
|
276
|
280
|
{
|
277
|
281
|
return Execute(() =>
|
278
|
282
|
{
|
279
|
|
- var models = GetEditQueryable().Where(predicate);
|
|
283
|
+ var models = GetEditQueryable().Where(predicate).AsNoTracking();
|
280
|
284
|
var editedDbos = new List<TDboRead>();
|
281
|
285
|
foreach (var model in models)
|
282
|
286
|
{
|
|
@@ -353,7 +357,7 @@ namespace Luticate2.Utils.DataAccess
|
353
|
357
|
{
|
354
|
358
|
return Execute(() =>
|
355
|
359
|
{
|
356
|
|
- var models = GetDeleteQueryable().Where(predicate).ToList();
|
|
360
|
+ var models = GetDeleteQueryable().Where(predicate).AsNoTracking().ToList();
|
357
|
361
|
Table.RemoveRange(models);
|
358
|
362
|
Db.SaveChanges();
|
359
|
363
|
var dbos = models.Select(GetDboFromModel);
|