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