Add VwmyCatalog view entity and update repository usage

Introduce VwmyCatalog as a keyless entity mapped to the VWMY_CATALOG database view. Update ApplicationDbContext to include the new DbSet and configure its mapping. Modify CatalogRepository to query the view instead of the table for GetAllAsync and GetByIdAsync. Add AutoMapper configuration for VwmyCatalog to Catalog. Add the VwmyCatalog entity class.
This commit is contained in:
OlgunR
2026-01-12 17:00:37 +01:00
parent 97eea94090
commit ce40abe20f
4 changed files with 55 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ public partial class ApplicationDbContext : DbContext
}
public virtual DbSet<TbmyCatalog> TbmyCatalogs { get; set; }
public virtual DbSet<VwmyCatalog> VwmyCatalogs { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -49,6 +50,37 @@ public partial class ApplicationDbContext : DbContext
.HasColumnName("CHANGED_WHO");
});
modelBuilder.Entity<VwmyCatalog>(entity =>
{
entity.HasNoKey();
entity.ToView("VWMY_CATALOG");
entity.Property(e => e.Guid).HasColumnName("GUID");
entity.Property(e => e.AddedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName("ADDED_WHO");
entity.Property(e => e.AddedWhen)
.HasColumnType("datetime")
.HasColumnName("ADDED_WHEN");
entity.Property(e => e.CatString)
.HasMaxLength(900)
.IsUnicode(false)
.HasColumnName("CAT_STRING");
entity.Property(e => e.CatTitle)
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnName("CAT_TITLE");
entity.Property(e => e.ChangedWhen)
.HasColumnType("datetime")
.HasColumnName("CHANGED_WHEN");
entity.Property(e => e.ChangedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName("CHANGED_WHO");
});
OnModelCreatingPartial(modelBuilder);
}