You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuUtilsPkBigSerialDataAccess.cs 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Linq.Expressions;
  3. using Luticate2.Utils.DataAccess;
  4. using Luticate2.Utils.Dbo.Filter;
  5. using Microsoft.EntityFrameworkCore;
  6. using TestUtils.DataAccess.Models;
  7. using TestUtils.Dbo.PkBigSerial;
  8. namespace TestUtils.DataAccess
  9. {
  10. public class LuUtilsPkBigSerialDataAccess : LuEfCrudDataAccess<pk_bigserial, PkBigSerialAddDbo, PkBigSerialDbo, PkBigSerialAddDbo, LuUtilsDbContext, long>
  11. {
  12. public LuUtilsPkBigSerialDataAccess(IServiceProvider serviceProvider) : base(serviceProvider)
  13. {
  14. }
  15. protected override DbSet<pk_bigserial> GetTable(LuUtilsDbContext db)
  16. {
  17. return db.pk_bigserial;
  18. }
  19. protected override pk_bigserial GetModelFromTCreate(PkBigSerialAddDbo obj)
  20. {
  21. return GetModelFromTUpdate(obj, new pk_bigserial());
  22. }
  23. protected override void EditModelFromTUpdate(PkBigSerialAddDbo obj, pk_bigserial model)
  24. {
  25. model.some_int = obj.SomeInt;
  26. model.some_text = obj.SomeText;
  27. }
  28. protected override PkBigSerialDbo GetDboFromModel(pk_bigserial model)
  29. {
  30. return new PkBigSerialDbo
  31. {
  32. CreatedAt = model.created_at,
  33. Id = model.id,
  34. SomeInt = model.some_int,
  35. SomeText = model.some_text
  36. };
  37. }
  38. protected override Expression<Func<pk_bigserial, bool>> GetFilterExpression(LuFilterDbo filter)
  39. {
  40. var query = filter.Query.ToLower();
  41. return model => model.some_text.ToLower().Contains(query) || model.some_int.ToString().Contains(query);
  42. }
  43. }
  44. }