コード例 #1
0
 private ColumnTypeEnum GetColumnType(CommonDataProvider provider, string tableName, string columnName)
 {
     string sql = string.Format("select data_type from information_schema.columns where table_name = '{0}' AND column_name = '{1}'", tableName, columnName);
     string val = provider.ExecuteScalar(sql).ToString();
     if (val == "char" || val == "nchar" || val == "nvarchar" || val == "varchar")
     {
         return ColumnTypeEnum.Varchar;
     }
     else if (val == "int")
     {
         return ColumnTypeEnum.Integer;
     }
     else if (val == "numeric")
     {
         return ColumnTypeEnum.Numeric;
     }
     else if (val == "decimal")
     {
         return ColumnTypeEnum.Decimal;
     }
     else if (val == "uniqueidentifier")
     {
         return ColumnTypeEnum.Uniqueidentifier;
     }
     else
     {
         return ColumnTypeEnum.Unknown;
     }
 }
コード例 #2
0
 private int GetColumnLength(CommonDataProvider provider, string tableName, string columnName)
 {
     string sql = string.Format("select character_maximum_length from information_schema.columns where table_name = '{0}' AND column_name = '{1}'", tableName, columnName);
     object val = provider.ExecuteScalar(sql);
     if (val == DBNull.Value) return 0;
     return Convert.ToInt32(val);
 }
コード例 #3
0
 public object GetProductDicitonaryValue(Guid productID, string property)
 {
     string sql = "select [{0}] from Product where ID = '{1}'";
     sql = string.Format(sql, property, productID);
     using (CommonDataProvider provider = new CommonDataProvider())
     {
         return provider.ExecuteScalar(sql);
     }
 }
コード例 #4
0
 public object GetProductDictionaryText(Guid entityID, DictionaryTree entity)
 {
     string sql = "select [{0}] from {1} where [{2}] = '{3}'";
     sql = string.Format(sql, entity.Dictionary.IdentifierField, entity.Dictionary.TableName, entity.PK, entityID);
     using (CommonDataProvider provider = new CommonDataProvider())
     {
         return provider.ExecuteScalar(sql);
     }
 }
コード例 #5
0
 public object GetDictionaryItemValue(Guid dictionaryTreeID, Guid entityID, string column)
 {
     DictionaryTree tree = DictionaryTrees.SingleOrDefault(d => d.ID == dictionaryTreeID);
     if (tree != null)
     {
         string sql = string.Format("select [{0}] from [{1}] where [{2}] = '{3}'", column, tree.Dictionary.TableName, tree.PK, entityID);
         using (CommonDataProvider domain = new CommonDataProvider())
         {
             return domain.ExecuteScalar(sql);
         }
     }
     return null;
 }