category
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
|
||||
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user