예제 #1
0
        public void AddEntity(Entity entity)
        {
            if (EntitiesUnclassified.ContainsKey(entity.Id))
            {
                return;
            }

            EntitiesAdded.Add(entity);
        }
예제 #2
0
        /// <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
            });
        }
예제 #3
0
        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();
        }
예제 #4
0
 public void SendEntitiesAdded(List <BaseEntity> newEntities)
 {
     EntitiesAdded?.Invoke(newEntities);
 }