public void AddEntity(Entity entity) { if (EntitiesUnclassified.ContainsKey(entity.Id)) { return; } EntitiesAdded.Add(entity); }
/// <summary> /// Add entity to collection /// </summary> /// <param name="entities">list of documents to add</param> /// <param name="token">cancellation token async support</param> /// <returns></returns> public virtual async Task Add(List <T> entities, CancellationToken token = default(CancellationToken)) { await Collection.InsertManyAsync(entities, new InsertManyOptions() { BypassDocumentValidation = true }, token); EntitiesAdded?.Invoke(this, new EntitiesEventArgs <T, TKey> { Entities = entities }); }
private void AddNewEntities(bool disableOnAdded = false) { foreach (var entity in EntitiesAdded) { if (!EntitiesUnclassified.ContainsKey(entity.Id)) { EntitiesUnclassified.Add(entity.Id, entity); } AddEntityToDictionary(entity); if (!disableOnAdded) { entity.Added(); } } EntitiesAdded.Clear(); }
public void SendEntitiesAdded(List <BaseEntity> newEntities) { EntitiesAdded?.Invoke(newEntities); }