Мне нужно массово вставить некоторые данные в мою базу данных, и я использую DDD и CQRS.
Это мой агрегат:
public class CategoryProperty : Aggregates, IAggregateMarker
{
#region BackingField
private string _propName;
private CategoryTypeProp _categoryPropertyType;
private Guid _categoryId;
#endregion
#region Properties
public string PropName { get => _propName; set => SetWithNotify(_propName, ref _propName); }
public CategoryTypeProp CategoryPropertyType { get => _categoryPropertyType; set => SetWithNotify(_categoryPropertyType, ref _categoryPropertyType); }
public Guid CategoryId { get => _categoryId; set => SetWithNotify(_categoryId, ref _categoryId); }
public Category Category { get; set; }
#endregion
public CategoryProperty()
{
}
public CategoryProperty(string propName, CategoryPropertyType categoryPropertyType, Category category)
{
PropName = propName ?? throw new ArgumentNullException();
CategoryPropertyType = new CategoryTypeProp(categoryPropertyType) ?? throw new ArgumentNullException();
Category = category ?? throw new ArgumentNullException();
}
#region SetValue
public void SetValues(string propName, CategoryPropertyType categoryPropertyType, Category category)
{
PropName = propName ?? throw new ArgumentNullException();
CategoryPropertyType = new CategoryTypeProp(categoryPropertyType) ?? throw new ArgumentNullException();
Category = category ?? throw new ArgumentNullException();
}
#endregion
}
, а это моя команда:
public class CreateCategoryPropertyCommand : IRequest<OperationResult<string>>
{
public List<CategoryPropertyDto> CategoryPropertyDtos { get; set; }
}
и это Repository :
public async Task<OperationResult<string>> AddBulkCategoryProperty(List<CategoryProperty> category, CancellationToken cancellation)
{
try
{
await context.BulkInsertAsync(category);
return OperationResult<string>.BuildSuccessResult("Succes Add");
}
catch (Exception ex)
{
return OperationResult<string>.BuildFailure(ex.Message);
}
}
Теперь мне нужно найти лучший способ использования объемной вставки в DDD.
Как мне найти лучший способ объемной вставки в DDD?