Files
DbFirst/DbFirst.Infrastructure/ApplicationDbContext.cs
OlgunR d78fd5e3d1 Add user-specific persistent grid/band layouts support
Implemented user-customizable, persistent grid and band layouts for CatalogsGrid and MassDataGrid. Added backend API, database entity, and repository for storing layouts per user. Refactored grids to support dynamic band/column rendering, layout management UI, and per-user storage via localStorage and the new API. Registered all necessary services and updated data context. Enables flexible, user-specific grid experiences with saved layouts.
2026-02-06 14:07:52 +01:00

91 lines
3.3 KiB
C#

using DbFirst.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace DbFirst.Infrastructure;
public partial class ApplicationDbContext : DbContext
{
private readonly TableConfigurations _config;
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options, IOptionsMonitor<TableConfigurations> configOptions)
: base(options)
{
_config = configOptions.CurrentValue;
}
public virtual DbSet<VwmyCatalog> VwmyCatalogs { get; set; }
public virtual DbSet<SmfLayout> SmfLayouts { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var catCfg = _config.VwmyCatalog;
modelBuilder.Entity<VwmyCatalog>(entity =>
{
entity.HasKey(e => e.Guid);
entity.ToView(catCfg.ViewName);
entity.Property(e => e.Guid).HasColumnName(catCfg.GuidColumnName);
entity.Property(e => e.AddedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName(catCfg.AddedWhoColumnName);
entity.Property(e => e.AddedWhen)
.HasColumnType("datetime")
.HasColumnName(catCfg.AddedWhenColumnName);
entity.Property(e => e.CatString)
.HasMaxLength(900)
.IsUnicode(false)
.HasColumnName(catCfg.CatStringColumnName);
entity.Property(e => e.CatTitle)
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnName(catCfg.CatTitleColumnName);
entity.Property(e => e.ChangedWhen)
.HasColumnType("datetime")
.HasColumnName(catCfg.ChangedWhenColumnName);
entity.Property(e => e.ChangedWho)
.HasMaxLength(30)
.IsUnicode(false)
.HasColumnName(catCfg.ChangedWhoColumnName);
});
modelBuilder.Entity<SmfLayout>(entity =>
{
entity.HasKey(e => e.Guid);
entity.ToTable("TBDD_SMF_LAYOUT", tb => tb.HasTrigger("TBDD_SMF_LAYOUT_AFT_UPD"));
entity.Property(e => e.Guid).HasColumnName("GUID");
entity.Property(e => e.Active).HasColumnName("ACTIVE");
entity.Property(e => e.LayoutType)
.HasMaxLength(50)
.HasColumnName("LAYOUT_TYPE");
entity.Property(e => e.LayoutKey)
.HasMaxLength(150)
.HasColumnName("LAYOUT_KEY");
entity.Property(e => e.UserName)
.HasMaxLength(50)
.HasColumnName("USER_NAME");
entity.Property(e => e.LayoutData).HasColumnName("LAYOUT_DATA");
entity.Property(e => e.AddedWho)
.HasMaxLength(50)
.HasColumnName("ADDED_WHO");
entity.Property(e => e.AddedWhen)
.HasColumnType("datetime")
.HasColumnName("ADDED_WHEN");
entity.Property(e => e.ChangedWho)
.HasMaxLength(50)
.HasColumnName("CHANGED_WHO");
entity.Property(e => e.ChangedWhen)
.HasColumnType("datetime")
.HasColumnName("CHANGED_WHEN");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}