This commit is contained in:
2026-04-22 22:37:31 +04:30
parent 15d11122b8
commit 6d35ef772c
8 changed files with 45 additions and 16 deletions
@@ -37,7 +37,11 @@ internal class CategoryConfiguration : BaseEntityConfiguration<Category, Categor
builder.Property(x => x.Path)
.HasField("_path")
.IsRequired()
.HasConversion(x => x.Value, x => Domain.Products.ValuesObjects.CategoryPath.CreateNew(x))
.HasConversion(
// Convert CategoryPath → HierarchyId
categoryPath => HierarchyId.Parse(categoryPath.Value),
// Convert HierarchyId → CategoryPath
hierarchyId => CategoryPath.CreateNew(hierarchyId.ToString()))
.HasColumnType("HIERARCHYID");
// ایندکس برای Path با نوع HIERARCHYID
@@ -28,7 +28,7 @@ public class GoldGalleryStartup
{
services.AddDbContext<GoldGalleryDbContext>(op =>
{
op.UseSqlServer(connectionString);
op.UseSqlServer(connectionString, sqlOptions => sqlOptions.UseHierarchyId());
});
services.AddScoped<DbContext>(sp => sp.GetRequiredService<GoldGalleryDbContext>());
services.AddScoped<IGoldGalleryModule, GoldGalleryModule>();