コード例 #1
0
 protected void Increment(Guid id, string propertyName)
 {
     try
     {
         MetaDataMember member      = m_objectMapper.GetMember(propertyName);
         string         commandText = "update " + m_objectMapper.TableName + " set " + propertyName + " = " + propertyName + " + 1 where id = '" + id + "'";
         ExecuteCommand(commandText);
     }
     catch (Exception excp)
     {
         logger.Error("Exception SIPAssetPersistor IncrementProperty (for " + typeof(T).Name + "). " + excp.Message);
         throw;
     }
 }
コード例 #2
0
        public override void UpdateProperty(Guid id, string propertyName, object value)
        {
            try
            {
                using (IDbConnection connection = m_dbProviderFactory.CreateConnection())
                {
                    connection.ConnectionString = m_dbConnectionStr;
                    connection.Open();

                    IDbCommand updateCommand = connection.CreateCommand();

                    MetaDataMember member        = m_objectMapper.GetMember(propertyName);
                    string         parameterName = "1";
                    DbParameter    dbParameter   = base.GetParameter(m_dbProviderFactory, member, value, parameterName);
                    updateCommand.Parameters.Add(dbParameter);

                    updateCommand.CommandText = "update " + m_objectMapper.TableName + " set " + propertyName + " = ?" + parameterName + " where id = '" + id + "'";
                    updateCommand.ExecuteNonQuery();
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SQLAssetPersistor UpdateProperty (for " + typeof(T).Name + "). " + excp.Message);
                throw;
            }
        }