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.

LuUtilsPkGuidDataAccess.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Linq.Expressions;
  3. using Luticate2.Utils.DataAccess;
  4. using Luticate2.Utils.Dbo.Filter;
  5. using Test.Utils.DataAccess.Models;
  6. using Test.Utils.Dbo.PkGuid;
  7. namespace Test.Utils.DataAccess
  8. {
  9. public class LuUtilsPkGuidDataAccess : LuEfCrudDataAccess<pk_guid, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo, LuUtilsDbContext, string>
  10. {
  11. public LuUtilsPkGuidDataAccess(LuUtilsDbContext db) : base(db, db.pk_guid)
  12. {
  13. }
  14. protected override pk_guid GetModelFromTCreate(PkGuidAddDbo obj)
  15. {
  16. return GetModelFromTUpdate(obj, new pk_guid());
  17. }
  18. protected override void EditModelFromTUpdate(PkGuidAddDbo obj, pk_guid model)
  19. {
  20. model.some_int = obj.SomeInt;
  21. model.some_text = obj.SomeText;
  22. }
  23. protected override PkGuidDbo GetDboFromModel(pk_guid model)
  24. {
  25. return new PkGuidDbo
  26. {
  27. CreatedAt = model.created_at,
  28. UpdatedAt = model.updated_at,
  29. Id = model.id.ToString(),
  30. SomeInt = model.some_int,
  31. SomeText = model.some_text
  32. };
  33. }
  34. protected override Expression<Func<pk_guid, bool>> GetFilterExpression(LuFilterDbo filter)
  35. {
  36. return model => LuUtilsDbContext.lu_texts_match(filter.Query, model.some_text + " " + model.some_int.ToString());
  37. }
  38. }
  39. }