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.

LuUtilsFkPkGuidDataAccess.cs 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Linq;
  3. using Luticate2.Utils.DataAccess;
  4. using Microsoft.EntityFrameworkCore;
  5. using TestUtils.DataAccess.Models;
  6. using TestUtils.Dbo.FkPkGuid;
  7. namespace TestUtils.DataAccess
  8. {
  9. public class LuUtilsFkPkGuidDataAccess : LuEfCrudDataAccess<fk_pk_guids, FkPkGuidAddDbo, FkPkGuidDbo, FkPkGuidAddDbo, LuUtilsDbContext, string>
  10. {
  11. public LuUtilsFkPkGuidDataAccess(IServiceProvider serviceProvider) : base(serviceProvider)
  12. {
  13. }
  14. protected override DbSet<fk_pk_guids> GetTable(LuUtilsDbContext db)
  15. {
  16. return db.fk_pk_guids;
  17. }
  18. protected override IQueryable<fk_pk_guids> GetGetQueryable(LuUtilsDbContext db, DbSet<fk_pk_guids> table)
  19. {
  20. return table.Include(guids => guids.fk_pk_guid);
  21. }
  22. protected override fk_pk_guids GetModelFromTCreate(FkPkGuidAddDbo obj)
  23. {
  24. return GetModelFromTUpdate(obj, new fk_pk_guids());
  25. }
  26. protected override void EditModelFromTUpdate(FkPkGuidAddDbo obj, fk_pk_guids model)
  27. {
  28. model.name = obj.Name;
  29. model.pk_guid_id = obj.PkGuidId == null ? (Guid?) null : new Guid(obj.PkGuidId);
  30. }
  31. protected override FkPkGuidDbo GetDboFromModel(fk_pk_guids model)
  32. {
  33. return new FkPkGuidDbo
  34. {
  35. Id = model.id.ToString(),
  36. Name = model.name,
  37. PkGuid = model.fk_pk_guid == null ? null : LuUtilsPkGuidDataAccess.GetDboFromModelStatic(model.fk_pk_guid),
  38. PkGuidId = model.pk_guid_id?.ToString()
  39. };
  40. }
  41. }
  42. }