public void Add <TEntity>(TEntity entity)
            where TEntity : class
        {
            ICollection <TEntity> entityCollection = (ICollection <TEntity>)GetCollection(typeof(TEntity));

            if (AutogenerateId)
            {
                PropertyInfo keyPropertyInfo = DynamicLambdaBuilder.GetKeyProperty <TEntity>(typeof(PersistenceIdAttribute));
                if (keyPropertyInfo != default)
                {
                    keyPropertyInfo.SetValue(entity, ObjectId.GenerateNewId());
                }
                else
                {
                    entity.GetType().GetProperty("Id").SetValue(entity, ObjectId.GenerateNewId());
                }
            }
            entityCollection.Add(entity);
        }
        public void Add <TEntity>(IEnumerable <TEntity> entityList) where TEntity : class
        {
            PropertyInfo keyPropertyInfo = AutogenerateId ?
                                           DynamicLambdaBuilder.GetKeyProperty <TEntity>(typeof(PersistenceIdAttribute)) : default;

            ICollection <TEntity> entityCollection = (ICollection <TEntity>)GetCollection(typeof(TEntity));

            foreach (var entity in entityList)
            {
                if (keyPropertyInfo != default)
                {
                    keyPropertyInfo.SetValue(entity, ObjectId.GenerateNewId());
                }
                else
                {
                    entity.GetType().GetProperty("Id").SetValue(entity, ObjectId.GenerateNewId());
                }
                entityCollection.Add(entity);
            }
        }
        public void Update <TEntity>(TEntity entity)
            where TEntity : class
        {
            ICollection <TEntity> collection      = (ICollection <TEntity>)GetCollection(typeof(TEntity));
            List <TEntity>        nCollection     = new List <TEntity>();
            PropertyInfo          keyPropertyInfo = AutogenerateId ?
                                                    DynamicLambdaBuilder.GetKeyProperty <TEntity>(typeof(PersistenceIdAttribute)) :
                                                    entity.GetType().GetProperty("Id")
            ;

            foreach (var _entity in collection)
            {
                if (keyPropertyInfo.GetValue(entity).Equals(keyPropertyInfo.GetValue(_entity)))
                {
                    continue;
                }
                nCollection.Add(_entity);
            }
            nCollection.Add(entity);
            UpdateCollection(typeof(TEntity), nCollection);
        }