Esempio n. 1
0
        public void Delete <TDocument>(TDocument instance) where TDocument : class
        {
            EntityMapping mapping;

            if (!_mappings.TryGet(instance.GetType(), out mapping))
            {
                mapping = _mappings.Get(typeof(TDocument));
            }
            string            statement         = string.Format("DELETE from NuFridge.[{0}] WHERE Id = @Id", mapping.TableName);
            CommandParameters commandParameters = new CommandParameters();

            commandParameters.Add("Id", mapping.IdColumn.ReaderWriter.Read(instance));
            CommandParameters args = commandParameters;

            using (SqlCommand command = CreateCommand(statement, args))
            {
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    throw WrapException(command, ex);
                }
            }
        }
Esempio n. 2
0
 public IQueryBuilder <TRecord> Parameter(string name, object value)
 {
     _parameters.Add(name, value);
     return(this);
 }