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
@@ -35,7 +35,11 @@ internal class CategoryConfiguration : BaseEntityConfiguration<Category,Category
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");
+1 -1
View File
@@ -26,7 +26,7 @@ public class ShopStartup
{
services.AddDbContext<ShopDbContext>(op =>
{
op.UseSqlServer(connectionString);
op.UseSqlServer(connectionString, sqlOption=> sqlOption.UseHierarchyId());
});
services.AddScoped<DbContext>(sp => sp.GetRequiredService<ShopDbContext>());
services.AddScoped<IShopModule, ShopModule>();