Exemplo n.º 1
0
        public void AddEntity(Entity entity)
        {
            if (EntitiesUnclassified.ContainsKey(entity.Id))
            {
                return;
            }

            EntitiesAdded.Add(entity);
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 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();
        }
Exemplo n.º 4
0
 public void SendEntitiesAdded(List <BaseEntity> newEntities)
 {
     EntitiesAdded?.Invoke(newEntities);
 }