internal void Add(TEntity item, DateTime?moment, bool fireEvents) { if (item is null) { return; } LazyLoad(); LazySet(); if (EagerLoadLogic != null) { EagerLoadLogic.Invoke(item); } if (fireEvents) { if (ParentProperty?.RaiseOnChange((OGMImpl)Parent, default(TEntity), item, moment, OperationEnum.Add) ?? false) { return; } } CollectionItem <TEntity> oldItem = InnerData.FirstOrDefault(item => item.Item.GetKey() == item.Item.GetKey()); ExecuteAction(AddAction(item, (oldItem != null) ? oldItem.StartDate : moment)); }
internal void AddRange(IEnumerable <TEntity> items, DateTime?moment, bool fireEvents) { LazyLoad(); LazySet(); LinkedList <RelationshipAction> actions = new LinkedList <RelationshipAction>(); foreach (var item in items) { if (item is null) { continue; } if (EagerLoadLogic != null) { EagerLoadLogic.Invoke(item); } if (fireEvents) { if (ParentProperty?.RaiseOnChange((OGMImpl)Parent, default(TEntity), item, moment, OperationEnum.Add) ?? false) { continue; } } CollectionItem <TEntity> oldItem = InnerData.FirstOrDefault(item => item.Item.GetKey() == item.Item.GetKey()); actions.AddLast(AddAction(item, (oldItem != null) ? oldItem.StartDate : moment)); } ExecuteAction(actions); }