|
@@ -24,31 +24,25 @@ namespace Comal.Stores
|
|
|
if (entity.GetOriginalValue(x => x.ID, entity.ID) == Guid.Empty)
|
|
|
return;
|
|
|
|
|
|
- _stockentitytypes ??= CoreUtils.TypeList(x => x.IsSubclassOf(typeof(StockEntity)));
|
|
|
+ _stockentitytypes ??= CoreUtils.TypeList(x =>
|
|
|
+ x.IsSubclassOf(typeof(StockEntity))
|
|
|
+ && !x.HasAttribute<AutoEntity>()
|
|
|
+ && x.HasInterface<IPersistent>());
|
|
|
var _uom = Provider.Query(new Filter<ProductDimensionUnit>(x => x.ID).IsEqualTo(entity.UnitOfMeasure.ID))
|
|
|
.ToObjects<ProductDimensionUnit>().FirstOrDefault() ?? new ProductDimensionUnit();
|
|
|
- //List<Task> _tasks = new List<Task>();
|
|
|
foreach (var _stockentitytype in _stockentitytypes)
|
|
|
{
|
|
|
- //var _task = Task.Run(() =>
|
|
|
- //{
|
|
|
- var _children = Provider.Query(
|
|
|
- _stockentitytype,
|
|
|
- new Filter<StockEntity>(x => x.Product.ID).IsEqualTo(entity.ID),
|
|
|
- Columns.None<StockEntity>()
|
|
|
- .Add(x => x.ID)
|
|
|
- .AddSubColumns(x => x.Dimensions, null)
|
|
|
- ).ToObjects(_stockentitytype).OfType<StockEntity>().ToArray();
|
|
|
- foreach (var _child in _children)
|
|
|
- _child.Dimensions.Unit.CopyFrom(_uom);
|
|
|
- var _updates = _children.Where(x => x.IsChanged()).ToArray();
|
|
|
- if (_updates.Any())
|
|
|
- Provider.Save(_stockentitytype,_updates);
|
|
|
- //});
|
|
|
- //_tasks.Add(_task);
|
|
|
+ var _children = (Provider.Query(
|
|
|
+ _stockentitytype,
|
|
|
+ new Filter<StockEntity>(x => x.Product.ID).IsEqualTo(entity.ID),
|
|
|
+ Columns.None<StockEntity>()
|
|
|
+ .Add(x => x.ID)
|
|
|
+ .AddSubColumns(x => x.Dimensions, null)
|
|
|
+ ).ToArray(_stockentitytype) as StockEntity[])!;
|
|
|
+ foreach (var _child in _children)
|
|
|
+ _child.Dimensions.Unit.CopyFrom(_uom);
|
|
|
+ Provider.Save(_stockentitytype, _children.Where(x => x.IsChanged()));
|
|
|
}
|
|
|
-
|
|
|
- //Task.WaitAll(_queries.ToArray());
|
|
|
}
|
|
|
|
|
|
protected override void AfterDelete(Product entity)
|