123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Linq.Expressions;
- using Luticate2.Utils.DataAccess;
- using Luticate2.Utils.Dbo.Filter;
- using Microsoft.EntityFrameworkCore;
- using TestUtils.DataAccess.Models;
- using TestUtils.Dbo.PkBigSerial;
-
- namespace TestUtils.DataAccess
- {
- public class LuUtilsPkBigSerialDataAccess : LuEfCrudDataAccess<pk_bigserial, PkBigSerialAddDbo, PkBigSerialDbo, PkBigSerialAddDbo, LuUtilsDbContext, long>
- {
- public LuUtilsPkBigSerialDataAccess(IServiceProvider serviceProvider) : base(serviceProvider)
- {
- }
-
- protected override DbSet<pk_bigserial> GetTable(LuUtilsDbContext db)
- {
- return db.pk_bigserial;
- }
-
- protected override pk_bigserial GetModelFromTCreate(PkBigSerialAddDbo obj)
- {
- return GetModelFromTUpdate(obj, new pk_bigserial());
- }
-
- protected override void EditModelFromTUpdate(PkBigSerialAddDbo obj, pk_bigserial model)
- {
- model.some_int = obj.SomeInt;
- model.some_text = obj.SomeText;
- }
-
- protected override PkBigSerialDbo GetDboFromModel(pk_bigserial model)
- {
- return model.ToDbo();
- }
-
- protected override Expression<Func<pk_bigserial, bool>> GetFilterExpression(LuFilterDbo filter)
- {
- if (filter == null)
- {
- return x => true;
- }
- var query = filter.Query.ToLower();
- return model => model.some_text.ToLower().Contains(query) || model.some_int.ToString().Contains(query);
- }
- }
- }
|