瀏覽代碼

Basic write to DB working

develop
Robin Thoni 5 年之前
父節點
當前提交
9f8a55db20

+ 225
- 17
Luticate2.Auth.Tests/DataAccess/Crud/LuEfCrudTests.cs 查看文件

@@ -1,5 +1,6 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3
+using System.Linq;
3 4
 using System.Linq.Expressions;
4 5
 using Luticate2.Auth.Tests.DataAccess.Crud.Models;
5 6
 using Luticate2.Auth.Utils.Business.Converters;
@@ -17,7 +18,7 @@ using Xunit;
17 18
 
18 19
 namespace Luticate2.Auth.Tests.DataAccess.Crud
19 20
 {
20
-    public class LuEfCrudTests
21
+    public class LuEfCrudTests : IDisposable
21 22
     {
22 23
         public class TableSimple1Dbo
23 24
         {
@@ -50,6 +51,20 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
50 51
             }
51 52
         }
52 53
 
54
+        public class TableSimple1ModelDescriptor : LuObjectConverterDescriptor<table_simple_1, TableSimple1Dbo>
55
+        {
56
+            public TableSimple1ModelDescriptor()
57
+            {
58
+                AddStaticMemberConverter(model => model.id, dbo => dbo.Id);
59
+                AddStaticMemberConverter(model => model.name, dbo => dbo.Name);
60
+                AddStaticMemberConverter(model => model.priority, dbo => dbo.Priority);
61
+                AddStaticMemberConverter(model => model.comment, dbo => dbo.Comment);
62
+                AddStaticMemberConverter(model => model.optional_int, dbo => dbo.OptionalInt);
63
+                AddStaticMemberConverter(model => model.created_at, dbo => dbo.CreatedAt);
64
+                AddStaticMemberConverter(model => model.updated_at, dbo => dbo.UpdatedAt);
65
+            }
66
+        }
67
+
53 68
         public class TableSimple1DataAccess : LuEfCrudDataAccess<TableSimple1Dbo, table_simple_1, luticate2_unit_testsContext>
54 69
         {
55 70
             public TableSimple1DataAccess(IServiceProvider serviceProvider) : base(serviceProvider)
@@ -57,14 +72,30 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
57 72
             }
58 73
         }
59 74
 
60
-        protected IServiceProvider GetServiceProvider()
75
+        public IServiceProvider ServiceProvider { get; set; }
76
+
77
+        public luticate2_unit_testsContext Luticate2UnitTestsContext { get; set; }
78
+
79
+        public LuEfCrudTests()
61 80
         {
62 81
             var services = new ServiceCollection();
63 82
             services.AddLuObjectConverterDescriptors();
83
+            // DB read
64 84
             services.AddSingleton<ILuObjectConverterDescriptor<TableSimple1Dbo, table_simple_1>, TableSimple1DboDescriptor>();
85
+            // DB write
86
+            services.AddSingleton<ILuObjectConverterDescriptor<table_simple_1, TableSimple1Dbo>, TableSimple1ModelDescriptor>();
65 87
 
66 88
             services.AddLuObjectConverters();
67
-            services.AddLuObjectConverterPoco<table_simple_1, TableSimple1Dbo>(); // DB read
89
+            // DB read
90
+            services.AddLuObjectConverterPoco<table_simple_1, TableSimple1Dbo>();
91
+            // DB write
92
+            services.AddLuObjectConverterPoco<TableSimple1Dbo, table_simple_1>();
93
+
94
+
95
+            services.AddSingleton<ILuConvertersTypeConverter>(new LuConvertersTypeConverter(new Dictionary<Type, Type>
96
+            {
97
+                {typeof(TableSimple1Dbo), typeof(table_simple_1)} // DB read
98
+            }));
68 99
 
69 100
             services.AddDbContext<luticate2_unit_testsContext>(options =>
70 101
             {
@@ -75,21 +106,47 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
75 106
             }, ServiceLifetime.Transient);
76 107
 
77 108
             services.AddSingleton<TableSimple1DataAccess>();
78
-            services.AddSingleton<ILuConvertersTypeConverter>(new LuConvertersTypeConverter(new Dictionary<Type, Type>
79
-            {
80
-                {typeof(TableSimple1Dbo), typeof(table_simple_1)} // DB read
81
-            }));
82 109
 
83
-            var serviceProvider = services.BuildServiceProvider();
84
-            return serviceProvider;
110
+            ServiceProvider = services.BuildServiceProvider();
111
+            Luticate2UnitTestsContext = ServiceProvider.GetService<luticate2_unit_testsContext>();
112
+            Luticate2UnitTestsContext.table_simple_1.RemoveRange(Luticate2UnitTestsContext.table_simple_1);
113
+            Luticate2UnitTestsContext.SaveChanges();
114
+        }
115
+
116
+        public void Dispose()
117
+        {
118
+            Luticate2UnitTestsContext.table_simple_1.RemoveRange(Luticate2UnitTestsContext.table_simple_1);
119
+            Luticate2UnitTestsContext.SaveChanges();
120
+        }
121
+
122
+        protected void AddTableSimple1DataSet1()
123
+        {
124
+            Luticate2UnitTestsContext.table_simple_1.AddRange(new table_simple_1
125
+            {
126
+                name = "test2",
127
+                priority = 24,
128
+                comment = null,
129
+                optional_int = 1,
130
+                created_at = DateTime.Now,
131
+                updated_at = null
132
+            }, new table_simple_1
133
+            {
134
+                name = "test1",
135
+                priority = 42,
136
+                comment = null,
137
+                optional_int = null,
138
+                created_at = DateTime.Now,
139
+                updated_at = null
140
+            });
141
+            Luticate2UnitTestsContext.SaveChanges();
85 142
         }
86 143
 
87 144
         [Fact]
88 145
         public void TestSimpleReadFilter1()
89 146
         {
90
-            var serviceProvider = GetServiceProvider();
147
+            AddTableSimple1DataSet1();
91 148
 
92
-            var crudDataAccess = serviceProvider.GetRequiredService<TableSimple1DataAccess>();
149
+            var crudDataAccess = ServiceProvider.GetRequiredService<TableSimple1DataAccess>();
93 150
 
94 151
             var result = crudDataAccess.Read(LuPartialFieldsParser.Parse("*").Data, new LuPaginatedParamsDbo
95 152
             {
@@ -123,9 +180,9 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
123 180
         [Fact]
124 181
         public void TestSimpleReadOrderBy1()
125 182
         {
126
-            var serviceProvider = GetServiceProvider();
183
+            AddTableSimple1DataSet1();
127 184
 
128
-            var crudDataAccess = serviceProvider.GetRequiredService<TableSimple1DataAccess>();
185
+            var crudDataAccess = ServiceProvider.GetRequiredService<TableSimple1DataAccess>();
129 186
 
130 187
             var result = crudDataAccess.Read(LuPartialFieldsParser.Parse("*").Data, new LuPaginatedParamsDbo
131 188
             {
@@ -173,11 +230,11 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
173 230
         [Fact]
174 231
         public void TestSimpleReadOrderBy2()
175 232
         {
176
-            var serviceProvider = GetServiceProvider();
233
+            AddTableSimple1DataSet1();
177 234
 
178
-            var crudDataAccess = serviceProvider.GetRequiredService<TableSimple1DataAccess>();
235
+            var crudDataAccess = ServiceProvider.GetRequiredService<TableSimple1DataAccess>();
179 236
 
180
-            var partialRespone = new LuPartialFieldsDbo
237
+            var partialResponse = new LuPartialFieldsDbo
181 238
             {
182 239
                 Fields = new List<LuFieldDbo>
183 240
                 {
@@ -212,7 +269,7 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
212 269
                 PerPage = 10
213 270
             };
214 271
 
215
-            var result = crudDataAccess.Read(partialRespone, paginationParams);
272
+            var result = crudDataAccess.Read(partialResponse, paginationParams);
216 273
             Assert.NotNull(result);
217 274
             Assert.Equal(LuStatus.Success.ToInt(), result.Status);
218 275
             var items = result.Data;
@@ -235,5 +292,156 @@ namespace Luticate2.Auth.Tests.DataAccess.Crud
235 292
             Assert.Null(item.Comment);
236 293
             Assert.Equal(1, item.OptionalInt);
237 294
         }
295
+
296
+        [Fact]
297
+        public void TestSimpleCreate1()
298
+        {
299
+            var crudDataAccess = ServiceProvider.GetRequiredService<TableSimple1DataAccess>();
300
+
301
+            var partialInput = new LuPartialFieldsDbo
302
+            {
303
+                Fields = new List<LuFieldDbo>
304
+                {
305
+                    new LuFieldDbo
306
+                    {
307
+                        Parts = new List<string>
308
+                        {
309
+                            "*"
310
+                        }
311
+                    }
312
+                }
313
+            };
314
+
315
+            var partialResponse = new LuPartialFieldsDbo
316
+            {
317
+                Fields = new List<LuFieldDbo>
318
+                {
319
+                    new LuFieldDbo
320
+                    {
321
+                        Parts = new List<string>
322
+                        {
323
+                            "*"
324
+                        }
325
+                    }
326
+                }
327
+            };
328
+
329
+            var objects = new List<TableSimple1Dbo>
330
+            {
331
+                new TableSimple1Dbo
332
+                {
333
+                    Name = "test2",
334
+                    Priority = 24,
335
+                    Comment = null,
336
+                    OptionalInt = 1,
337
+                    CreatedAt = DateTime.Now,
338
+                    UpdatedAt = null
339
+                }, new TableSimple1Dbo
340
+                {
341
+                    Name = "test1",
342
+                    Priority = 42,
343
+                    Comment = null,
344
+                    OptionalInt = null,
345
+                    CreatedAt = DateTime.Now,
346
+                    UpdatedAt = null
347
+                }
348
+            };
349
+
350
+            var result = crudDataAccess.Create(partialResponse, partialInput, objects);
351
+
352
+            Assert.NotNull(result);
353
+            Assert.Equal(LuStatus.Success.ToInt(), result.Status);
354
+            var items = result.Data;
355
+            Assert.NotNull(items);
356
+            Assert.Equal(objects.Count, items.Count);
357
+
358
+            foreach (var o in items.Zip(objects, (added, origin) => new { Added = added, Origin = origin }))
359
+            {
360
+                Assert.NotNull(o.Added);
361
+                Assert.Equal(o.Origin.Name, o.Added.Name);
362
+                Assert.Equal(o.Origin.Priority, o.Added.Priority);
363
+                Assert.Equal(o.Origin.Comment, o.Added.Comment);
364
+                Assert.Equal(o.Origin.OptionalInt, o.Added.OptionalInt);
365
+            }
366
+        }
367
+
368
+        [Fact]
369
+        public void TestSimpleCreate2()
370
+        {
371
+            var crudDataAccess = ServiceProvider.GetRequiredService<TableSimple1DataAccess>();
372
+
373
+            var partialInput = new LuPartialFieldsDbo
374
+            {
375
+                Fields = new List<LuFieldDbo>
376
+                {
377
+                    new LuFieldDbo
378
+                    {
379
+                        Parts = new List<string>
380
+                        {
381
+                            "*"
382
+                        }
383
+                    }
384
+                }
385
+            };
386
+
387
+            var partialResponse = new LuPartialFieldsDbo
388
+            {
389
+                Fields = new List<LuFieldDbo>
390
+                {
391
+                    new LuFieldDbo
392
+                    {
393
+                        Parts = new List<string>
394
+                        {
395
+                            "id"
396
+                        }
397
+                    },
398
+                    new LuFieldDbo
399
+                    {
400
+                        Parts = new List<string>
401
+                        {
402
+                            "name"
403
+                        }
404
+                    }
405
+                }
406
+            };
407
+
408
+            var objects = new List<TableSimple1Dbo>
409
+            {
410
+                new TableSimple1Dbo
411
+                {
412
+                    Name = "test2",
413
+                    Priority = 24,
414
+                    Comment = null,
415
+                    OptionalInt = 1,
416
+                    CreatedAt = DateTime.Now,
417
+                    UpdatedAt = null
418
+                }, new TableSimple1Dbo
419
+                {
420
+                    Name = "test1",
421
+                    Priority = 42,
422
+                    Comment = null,
423
+                    OptionalInt = null,
424
+                    CreatedAt = DateTime.Now,
425
+                    UpdatedAt = null
426
+                }
427
+            };
428
+
429
+            var result = crudDataAccess.Create(partialResponse, partialInput, objects);
430
+
431
+            Assert.NotNull(result);
432
+            Assert.Equal(LuStatus.Success.ToInt(), result.Status);
433
+            var items = result.Data;
434
+            Assert.NotNull(items);
435
+            Assert.Equal(objects.Count, items.Count);
436
+
437
+            foreach (var o in items.Zip(objects, (added, origin) => new { Added = added, Origin = origin }))
438
+            {
439
+                Assert.NotNull(o.Added);
440
+                Assert.Equal(o.Origin.Name, o.Added.Name);
441
+                Assert.Equal(0, o.Added.Priority);
442
+                Assert.Null(o.Added.Comment);
443
+                Assert.Null(o.Added.OptionalInt);
444
+            }
445
+        }
238 446
     }
239 447
 }

+ 0
- 51
Luticate2.Auth/Auth/Business/LuGroupsBusiness.cs 查看文件

@@ -28,56 +28,5 @@ namespace Luticate2.Auth.Auth.Business
28 28
 
29 29
             return LuResult<IQueryable<LuGroups>>.Ok(included);
30 30
         }
31
-
32
-//        protected override LuResult<IQueryable<LuGroups>> Filter(LuFilterDbo filter, IQueryable<LuGroups> queryable)
33
-//        {
34
-//            return LuResult<IQueryable<LuGroups>>.Ok(queryable.Where(groups => groups.LuGroupsObjects.Any(objects => objects.Priority == 0)));
35
-//        }
36
-
37
-        public override LuResult<IList<LuGroupDbo>> Create(LuPartialFieldsDbo partialResponse,
38
-            LuPartialFieldsDbo partialInput, IEnumerable<LuGroupDbo> dbos)
39
-        {
40
-            var addedDbos = new List<LuGroupDbo>();
41
-            var addedModels = new List<LuGroups>();
42
-            var createResult = Execute((context, set) =>
43
-            {
44
-                foreach (var dbo in dbos)
45
-                {
46
-                    var addResult = ConvertDboToModel(partialInput, dbo);
47
-                    if (!addResult)
48
-                    {
49
-                        return addResult.To<bool>();
50
-                    }
51
-
52
-                    var model = addResult.Data;
53
-                    model.IdNavigation = new LuObjectsMetadata();
54
-                    set.Add(model);
55
-                    addedModels.Add(model);
56
-                }
57
-
58
-                context.SaveChanges();
59
-
60
-                return LuResult<bool>.Ok(true);
61
-            });
62
-
63
-            if (!createResult)
64
-            {
65
-                return createResult.To<IList<LuGroupDbo>>();
66
-            }
67
-
68
-            var ids = addedModels.Select(x => x.Id);
69
-
70
-            foreach (var addedModel in addedModels)
71
-            {
72
-                var convertResult = ConvertModelToDbo(partialResponse, addedModel);
73
-                if (!convertResult)
74
-                {
75
-                    return convertResult.To<IList<LuGroupDbo>>();
76
-                }
77
-                addedDbos.Add(convertResult.Data);
78
-            }
79
-
80
-            return LuResult<IList<LuGroupDbo>>.Ok(addedDbos);
81
-        }
82 31
     }
83 32
 }

+ 63
- 44
Luticate2.Auth/Utils/DataAccess/Crud/LuEfCrudDataAccess.cs 查看文件

@@ -40,45 +40,26 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
40 40
             };
41 41
         }
42 42
 
43
-        protected virtual LuResult<TModel> ConvertDboToModel(LuPartialFieldsDbo partialInput, TDbo dbo)
43
+        protected virtual LuResult<TTypeTo> Convert<TTypeTo>(LuPartialFieldsDbo partialInput, object dbo, LuConvertersOptions options) where TTypeTo : class
44 44
         {
45
-            var copier = ServiceProvider.GetService<ILuObjectConverter<TDbo, TModel>>();
46
-            if (copier == null)
45
+            var typeTo = dbo.GetType();
46
+            var converterType = typeof(ILuObjectConverter<,>);
47
+            var gConverterType = converterType.MakeGenericType(typeTo, typeof(TTypeTo));
48
+            var converter = (ILuObjectConverter) ServiceProvider.GetService(gConverterType);
49
+            if (converter == null)
47 50
             {
48
-                return LuResult<TModel>.Error(LuStatus.InternalError.ToInt(),
49
-                    $"Could not get service: {nameof(ILuObjectConverter)}<{typeof(TDbo).Name}, {typeof(TModel).Name}>");
51
+                return LuResult<TTypeTo>.Error(LuStatus.InternalError.ToInt(),
52
+                    $"Could not get service: {nameof(ILuObjectConverter)}<{typeof(TDbo).Name}, {typeof(TTypeTo).Name}>");
50 53
             }
51 54
 
52
-            var options = GetOptions();
53
-            var dstObjResult = options.Allocator.GetInstance(typeof(TModel));
54
-            if (!dstObjResult)
55
-            {
56
-                return dstObjResult.To<TModel>();
57
-            }
58
-            var dstObj = dstObjResult.Data;
59
-            var result = copier.Convert(dbo, dstObj, new LuFieldDbo(), partialInput, GetOptions());
60
-            return result.Select(o => o as TModel);
61
-        }
62
-
63
-        protected virtual LuResult<TDbo> ConvertModelToDbo(LuPartialFieldsDbo partialResponse, TModel model)
64
-        {
65
-            var copier = ServiceProvider.GetService<ILuObjectConverter<TModel, TDbo>>();
66
-            if (copier == null)
67
-            {
68
-                return LuResult<TDbo>.Error(LuStatus.InternalError.ToInt(),
69
-                    $"Could not get service: {nameof(ILuObjectConverter)}<{typeof(TModel).Name}, {typeof(TDbo).Name}>");
70
-            }
71
-
72
-            var options = GetOptions();
73
-            var dstObjResult = options.Allocator.GetInstance(typeof(TDbo));
55
+            var dstObjResult = options.Allocator.GetInstance(typeof(TTypeTo));
74 56
             if (!dstObjResult)
75 57
             {
76
-                return dstObjResult.To<TDbo>();
58
+                return dstObjResult.To<TTypeTo>();
77 59
             }
78 60
             var dstObj = dstObjResult.Data;
79
-
80
-            var result = copier.Convert(model, dstObj, new LuFieldDbo(), partialResponse, GetOptions());
81
-            return result.Select(o => o as TDbo);
61
+            var result = converter.Convert(dbo, dstObj, new LuFieldDbo(), partialInput, options);
62
+            return result.Select(o => o as TTypeTo);
82 63
         }
83 64
 
84 65
         protected virtual LuResult<T> HandleError<T>(Exception e)
@@ -107,26 +88,24 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
107 88
             return LuResult<IQueryable<TModel>>.Ok(queryable);
108 89
         }
109 90
 
110
-        protected virtual LuResult<IQueryable<TModel>> Filter(LuFilterDbo filter, IQueryable<TModel> queryable)
91
+        protected virtual LuResult<IQueryable<TModel>> Filter(LuFilterDbo filter, IQueryable<TModel> queryable, LuConvertersOptions options)
111 92
         {
112 93
             if (filter.Expression == null)
113 94
             {
114 95
                 return LuResult<IQueryable<TModel>>.Ok(queryable);
115 96
             }
116 97
 
117
-            var lambdaDbo = (Expression<Func<TDbo, bool>>) filter.Expression;
98
+            var lambdaDbo = filter.Expression as Expression<Func<TDbo, bool>>;
118 99
 
119
-            var options = GetOptions();
120 100
             var converter = new LuExpressionConverterVisitor(options, ServiceProvider);
121 101
             var lambdaModel = converter.Visit(lambdaDbo) as Expression<Func<TModel, bool>>;// TODO Handle errors
122 102
             return LuResult<IQueryable<TModel>>.Ok(queryable.Where(lambdaModel));
123 103
         }
124 104
 
125
-        protected virtual LuResult<IQueryable<TModel>> OrderByField(LuOrderByFieldDbo orderByField, IQueryable<TModel> queryable)
105
+        protected virtual LuResult<IQueryable<TModel>> OrderByField(LuOrderByFieldDbo orderByField, IQueryable<TModel> queryable, LuConvertersOptions options)
126 106
         {
127
-            var lambdaDbo = (Expression<Func<TDbo, object>>) orderByField.Expression;
107
+            var lambdaDbo = orderByField.Expression as Expression<Func<TDbo, object>>;
128 108
 
129
-            var options = GetOptions();
130 109
             var converter = new LuExpressionConverterVisitor(options, ServiceProvider);
131 110
             var lambdaModelNoConvert = converter.Visit(lambdaDbo) as LambdaExpression;// TODO Handle errors
132 111
             var lambdaModel = Expression.Lambda<Func<TModel, object>>(lambdaModelNoConvert.Body, lambdaModelNoConvert.Parameters);
@@ -159,12 +138,12 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
159 138
             return LuResult<IQueryable<TModel>>.Ok(ordered);
160 139
         }
161 140
 
162
-        protected virtual LuResult<IQueryable<TModel>> OrderBy(LuOrderByDbo orderBy, IQueryable<TModel> queryable)
141
+        protected virtual LuResult<IQueryable<TModel>> OrderBy(LuOrderByDbo orderBy, IQueryable<TModel> queryable, LuConvertersOptions options)
163 142
         {
164 143
             var ordered = queryable;
165 144
             foreach (var field in orderBy.OrderByFields)
166 145
             {
167
-                var orderedResult = OrderByField(field, ordered);
146
+                var orderedResult = OrderByField(field, ordered, options);
168 147
                 if (!orderedResult)
169 148
                 {
170 149
                     return orderedResult.To<IQueryable<TModel>>();
@@ -182,15 +161,55 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
182 161
             return LuResult<IQueryable<TModel>>.Ok(paginated);
183 162
         }
184 163
 
185
-        public virtual LuResult<IList<TDbo>> Create(LuPartialFieldsDbo partialResponse, LuPartialFieldsDbo partialInput, IEnumerable<TDbo> dbos)
164
+        public virtual LuResult<IList<TDbo>> Create(LuPartialFieldsDbo partialResponse, LuPartialFieldsDbo partialInput, IEnumerable<object> dbos)
186 165
         {
187
-            throw new NotImplementedException();
166
+            var options = GetOptions();
167
+            var addedDbos = new List<TDbo>();
168
+            var addedModels = new List<TModel>();
169
+            var createResult = Execute((context, set) =>
170
+            {
171
+                foreach (var dbo in dbos)
172
+                {
173
+                    var convertResult = Convert<TModel>(partialInput, dbo, options);
174
+                    if (!convertResult)
175
+                    {
176
+                        return convertResult.To<bool>();
177
+                    }
178
+
179
+                    var model = convertResult.Data;
180
+                    set.Add(model);
181
+                    addedModels.Add(model);
182
+                }
183
+
184
+                context.SaveChanges();
185
+
186
+                return LuResult<bool>.Ok(true);
187
+            });
188
+
189
+            if (!createResult)
190
+            {
191
+                return createResult.To<IList<TDbo>>();
192
+            }
193
+
194
+            foreach (var addedModel in addedModels)
195
+            {
196
+                var convertResult = Convert<TDbo>(partialResponse, addedModel, options);
197
+                if (!convertResult)
198
+                {
199
+                    return convertResult.To<IList<TDbo>>();
200
+                }
201
+                addedDbos.Add(convertResult.Data);
202
+            }
203
+
204
+            return LuResult<IList<TDbo>>.Ok(addedDbos);
188 205
         }
189 206
 
190 207
         public virtual LuResult<LuPaginatedDbo<TDbo>> Read(LuPartialFieldsDbo partialResponse, LuPaginatedParamsDbo paginationParams)
191 208
         {
192 209
             var result = Execute((context, set) =>
193 210
             {
211
+                var options = GetOptions();
212
+
194 213
                 var includeResult = Include(partialResponse, set);
195 214
                 if (!includeResult)
196 215
                 {
@@ -198,14 +217,14 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
198 217
                 }
199 218
                 var included = includeResult.Data;
200 219
 
201
-                var orderByResult = OrderBy(paginationParams.OrderBy, included);
220
+                var orderByResult = OrderBy(paginationParams.OrderBy, included, options);
202 221
                 if (!orderByResult)
203 222
                 {
204 223
                     return orderByResult.To<LuPaginatedDbo<TDbo>>();
205 224
                 }
206 225
                 var ordered = orderByResult.Data;
207 226
                 
208
-                var filteredResult = Filter(paginationParams.Filter, ordered);
227
+                var filteredResult = Filter(paginationParams.Filter, ordered, options);
209 228
                 if (!filteredResult)
210 229
                 {
211 230
                     return filteredResult.To<LuPaginatedDbo<TDbo>>();
@@ -223,7 +242,7 @@ namespace Luticate2.Auth.Utils.DataAccess.Crud
223 242
                 var dboList = new List<TDbo>();
224 243
                 foreach (var model in paginated)
225 244
                 {
226
-                    var dboResult = ConvertModelToDbo(partialResponse, model);
245
+                    var dboResult = Convert<TDbo>(partialResponse, model, options);
227 246
                     if (!dboResult)
228 247
                     {
229 248
                         return dboResult.To<LuPaginatedDbo<TDbo>>();

+ 1
- 1
Luticate2.Auth/Utils/Interfaces/ILuCrud.cs 查看文件

@@ -7,7 +7,7 @@ namespace Luticate2.Auth.Utils.Interfaces
7 7
 {
8 8
     public interface ILuCrud<TDbo>
9 9
     {
10
-        LuResult<IList<TDbo>> Create(LuPartialFieldsDbo partialResponse, LuPartialFieldsDbo partialInput, IEnumerable<TDbo> dbos);
10
+        LuResult<IList<TDbo>> Create(LuPartialFieldsDbo partialResponse, LuPartialFieldsDbo partialInput, IEnumerable<object> dbos);
11 11
         
12 12
         LuResult<LuPaginatedDbo<TDbo>> Read(LuPartialFieldsDbo partialResponse, LuPaginatedParamsDbo paginationParams);
13 13
         

Loading…
取消
儲存