Refactor catalog CRUD to use stored procedures only

Removed direct usage of TbmyCatalog entity and DbSet. All create, update, and delete operations now use stored procedures. Entity lookups and mappings are performed via the VwmyCatalog view. Updated AutoMapper profile and DbContext configuration accordingly. Catalog creation now sets ChangedWho/ChangedWhen to "system" and current UTC time.
This commit is contained in:
OlgunR
2026-01-14 12:50:58 +01:00
parent 6f3c0e33fa
commit ccd97fe9d6
5 changed files with 51 additions and 108 deletions

View File

@@ -10,49 +10,13 @@ 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)
{
modelBuilder.Entity<TbmyCatalog>(entity =>
{
entity.HasKey(e => e.Guid);
entity.ToTable("TBMY_CATALOG");
entity.HasIndex(e => e.CatTitle, "UQ_TBMY_CATALOG_TITLE").IsUnique();
entity.Property(e => e.Guid).HasColumnName("GUID");
entity.Property(e => e.AddedWhen)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime")
.HasColumnName("ADDED_WHEN");
entity.Property(e => e.AddedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasDefaultValue("SYSTEM")
.HasColumnName("ADDED_WHO");
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");
});
modelBuilder.Entity<VwmyCatalog>(entity =>
{
entity.HasNoKey();
entity.HasKey(e => e.Guid);
entity.ToView("VWMY_CATALOG");