예제 #1
0
        public EventCommandStatus DeleteAll <T>(string collection, IEnumerable <T> entities) where T : class
        {
            EventCommandStatus cs = new EventCommandStatus();

            foreach (var item in entities)
            {
                cs = Delete(collection, item);
            }
            return(cs);
        }
예제 #2
0
        public EventCommandStatus Delete <T>(string collection, T entity)
        {
            var enttype = typeof(T);
            var pi      = enttype.GetProperty(DocumentMetadata.IdPropertyName);

            if (pi != null)
            {
                var cmd = new { _action = DensoBuiltinCommands.Delete, _id = pi.GetValue(entity, null), _collection = collection };
                return(EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(cmd)), this));
            }
            throw new DocumentWithoutIdException();
        }
예제 #3
0
        public EventCommandStatus SetAll <T>(string collection, IEnumerable <T> entity) where T : class
        {
            EventCommandStatus result = new EventCommandStatus();

            foreach (var item in entity)
            {
                result = Set <T>(collection, item);
            }
            return(result);
            //var cmd = new { _action = DensoBuiltinCommands.SetMany, _collection = collection, _value = entity };
            //return EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(cmd)), this);
        }
예제 #4
0
        public EventCommandStatus Flush(string collection)
        {
            var cmd = new { _action = DensoBuiltinCommands.CollectionFlush, _collection = collection };

            return(EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(cmd)), this));
        }
예제 #5
0
        public EventCommandStatus Flush <T>() where T : class
        {
            var cmd = new { _action = DensoBuiltinCommands.CollectionFlush, _collection = typeof(T).Name };

            return(EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(cmd)), this));
        }
예제 #6
0
 public EventCommandStatus Execute <T>(T command) where T : class
 {
     return(EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(command)), this));
 }
예제 #7
0
        public EventCommandStatus Set <T>(string collection, T entity) where T : class
        {
            var cmd = new { _action = DensoBuiltinCommands.Set, _collection = collection, _value = entity };

            return(EventCommandStatus.Create(_command.Execute(DataBase, JsonConvert.SerializeObject(cmd)), this));
        }