Exemplo n.º 1
0
 public static void AddOutputParameters <T>(this IDbCommand cmd, T parameters)
     where T : class
 {
     PropertyInfo[] properties = parameters.GetType().GetProperties();
     for (int i = 0; i < (int)properties.Length; i++)
     {
         PropertyInfo propertyInfo = properties[i];
         Type         propertyType = propertyInfo.PropertyType;
         string       name         = propertyInfo.Name;
         try
         {
             DbType dbType = propertyType.Translate();
             cmd.AddOutputParameter(name, dbType);
         }
         catch (ArgumentException argumentException)
         {
             throw new ArgumentException(string.Format("Cannot convert type for property '{0}'.", name), name, argumentException);
         }
     }
 }