コード例 #1
0
ファイル: ParameterMapper.cs プロジェクト: rally25rs/storm
 internal void MapResult(object instanceToLoad, StormParameterMappedAttribute attribute, OracleCommand cmd)
 {
     if (attribute.ParameterDirection == System.Data.ParameterDirection.Output || attribute.ParameterDirection == System.Data.ParameterDirection.InputOutput)
     {
         if ((attribute.SupressEvents & StormPersistenceEvents.Load) != StormPersistenceEvents.Load)
         {
             object dbValue = DbTypeMap.UnBoxOracleType(cmd.Parameters[attribute.ParameterName].Value);
             Type destType = attribute.AttachedTo.PropertyType;
             if (dbValue != null && dbValue != DBNull.Value)
                 attribute.AttachedTo.SetValue(instanceToLoad, Convert.ChangeType(dbValue, destType), null);
             else
                 attribute.AttachedTo.SetValue(instanceToLoad, null, null);
         }
     }
 }
コード例 #2
0
ファイル: SchemaValidator.cs プロジェクト: rally25rs/storm
        private void ValidateParameterMapping(DataTable procedureArgumentsTable, StormParameterMappedAttribute mapping)
        {
            // assuming the columns, in order, are: {ARGUMENT_NAME, DATA_TYPE, IN_OUT}
            string paramName = mapping.ParameterName.ToUpper();	// the names retreived from Oracle are all upper case.
            foreach (DataRow dr in procedureArgumentsTable.Rows)
            {
                if ((string)dr[0] == paramName)
                {
                    // check data type
                    OracleDbType columnType = DbTypeMap.ConvertNameToDbType((string)dr[1]);
                    Type systemType = DbTypeMap.ConvertDbTypeToType(columnType);
                    if (mapping.AttachedTo.PropertyType != systemType)
                        throw new StormConfigurationException("The parameter named [" + mapping.ParameterName + "] is of type [" + systemType.FullName + "] but is mapped to a property with type [" + mapping.AttachedTo.PropertyType.FullName + "].");

                    // check direction
                    if (mapping.ParameterDirection == ParameterDirection.Input)
                    {
                        if ((string)dr[2] != "IN")
                            throw new StormConfigurationException("Invalid mapping. The parameter named [" + mapping.ParameterName + "] is marked as an Input parameter, but the DB thinks it is [" + (string)dr[3] + "].");
                    }
                    else if (mapping.ParameterDirection == ParameterDirection.InputOutput)
                    {
                        if ((string)dr[2] != "IN/OUT")
                            throw new StormConfigurationException("Invalid mapping. The parameter named [" + mapping.ParameterName + "] is marked as an Input/Output parameter, but the DB thinks it is [" + (string)dr[3] + "].");
                    }
                    else if (mapping.ParameterDirection == ParameterDirection.Output)
                    {
                        if ((string)dr[2] != "OUT")
                            throw new StormConfigurationException("Invalid mapping. The parameter named [" + mapping.ParameterName + "] is marked as an Output parameter, but the DB thinks it is [" + (string)dr[3] + "].");
                    }

                    // valid mapping
                    return;
                }
            }
            throw new StormConfigurationException("Invalid mapping. No parameter named [" + mapping.ParameterName + "] exists.");
        }