Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LuUtilsPkBigSerialDataAccess.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 model.ToDbo();
  31. }
  32. protected override Expression<Func<pk_bigserial, bool>> GetFilterExpression(LuFilterDbo filter)
  33. {
  34. if (filter == null)
  35. {
  36. return x => true;
  37. }
  38. var query = filter.Query.ToLower();
  39. return model => model.some_text.ToLower().Contains(query) || model.some_int.ToString().Contains(query);
  40. }
  41. }
  42. }