当前位置: 首页>>代码示例>>C#>>正文


C# ColumnSchema类代码示例

本文整理汇总了C#中ColumnSchema的典型用法代码示例。如果您正苦于以下问题:C# ColumnSchema类的具体用法?C# ColumnSchema怎么用?C# ColumnSchema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ColumnSchema类属于命名空间,在下文中一共展示了ColumnSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSchema

        public DbSchema GetSchema()
        {
            var schema = new DbSchema();
            var map = _configuration.BuildMapping();
            var mappings = _configuration.ClassMappings;

            foreach(var class_map in mappings)
            {
                var table = class_map.Table;
                var table_schema = new TableSchema() {TableName = table.Name, SchemaName = table.Schema};
                foreach (var column in table.ColumnIterator)
                {

                    var type_code = column.GetSqlTypeCode(map);

                    var columnSchema = new ColumnSchema()
                                           {
                                               TableName = table_schema.TableName,
                                               ColumnName = column.Name,
                                               IsNullable = column.IsNullable,
                                               DatabaseType = type_code.DbType,
                                               Size = column.Length,
                                               Scale = column.Scale,
                                               Precision = column.Precision,
                                               IsPrimaryKey = table.PrimaryKey.Columns.Contains(column)
                                           };

                    // columnSchema.DatabaseType = property.GetSqlTypeCode(map).DbType;
                    table_schema.AddColumn(columnSchema);
                }
                schema.AddTable(table_schema);
            }
            return schema;
        }
开发者ID:jcteague,项目名称:SchemaMigrator,代码行数:34,代码来源:NhibernateSchemaBuilder.cs

示例2: BuildAlterColumnCommand

 public override string BuildAlterColumnCommand(ColumnSchema schema)
 {
     string sql = String.Format(
     @"ALTER TABLE {0} ALTER COLUMN {1}",
         Api.CommandBuilder.QuoteIdentifier(schema.TableName),
         ColumnSqlCommand(schema)
     );
     return sql;
 }
开发者ID:Kuick,项目名称:Kuicker,代码行数:9,代码来源:SqlClientBuilder.cs

示例3: GetColumnSize

    public string GetColumnSize(ColumnSchema column)
    {
        string columnSize = column.Size.ToString();

        if (column.NativeType == "numeric" && column.Precision != 0)
        {
            columnSize += "(" + column.Precision.ToString() + "," + column.Scale + ")";
        }

        return columnSize;
    }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:11,代码来源:DBDocumenterTemplate.cs

示例4: GetPropertyName

        public string GetPropertyName(ColumnSchema column)
        {
            string propertyName = column.Name;

            if (propertyName == column.Table.Name + "Name") return "Name";
            if (propertyName == column.Table.Name + "Description") return "Description";

            if (propertyName.EndsWith("TypeCode")) propertyName = propertyName.Substring(0, propertyName.Length - 4);

            return propertyName;
        }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:11,代码来源:TypedDataSet.cst.cs

示例5: GetPropertyNameFromColumn

 /// <summary>
 /// Helper for class generation from tables, converts a column name into a Property Name
 /// </summary>
 /// <param name="column"> Column to be converted</param>
 /// <param name="prefix">Add characters to column</param>
 /// <param name="strip">remove characters from column</param>
 /// <returns>string</returns>
 public static string GetPropertyNameFromColumn(ColumnSchema column, string prefix, string strip)
 {
     if (strip != string.Empty)
     {
         return prefix + column.Name.Replace(strip, "").ToCSharpIdentifier().ToPascalCase();
     }
     else
     {
         return prefix + column.Name.ToCSharpIdentifier().ToPascalCase();
     }
 }
开发者ID:smacinn,项目名称:CodeSmithHelper,代码行数:18,代码来源:DB.cs

示例6: GetReaderMethod

 public string GetReaderMethod(ColumnSchema column)
 {
     switch (column.DataType)
     {
         case DbType.Byte:
         {
             return "GetByte";
         }
         case DbType.Int16:
         {
             return "GetInt16";
         }
         case DbType.Int32:
         {
             return "GetInt32";
         }
         case DbType.Int64:
         {
             return "GetInt64";
         }
         case DbType.AnsiStringFixedLength:
         case DbType.AnsiString:
         case DbType.String:
         case DbType.StringFixedLength:
         {
             return "GetString";
         }
         case DbType.Boolean:
         {
             return "GetBoolean";
         }
         case DbType.Guid:
         {
             return "GetGuid";
         }
         case DbType.Currency:
         case DbType.Decimal:
         {
             return "GetDecimal";
         }
         case DbType.DateTime:
         case DbType.Date:
         {
             return "GetDateTime";
         }
         default:
         {
             return "__SQL__" + column.DataType;
         }
     }
 }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:51,代码来源:TypedDataSet.cst.cs

示例7: IsChildFKColumn

 public static bool IsChildFKColumn(ColumnSchema column, TableSchema table)
 {
     foreach (ReferenceSchema inReference in table.InReferences)
     {
         foreach (ReferenceJoin join in inReference.Joins)
         {
             //Found the child Column...
             if (join.ChildColumn.ObjectID == column.ObjectID)
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:15,代码来源:Helper.cs

示例8: GetCSharpTypeFromDBFieldType

	public string GetCSharpTypeFromDBFieldType(ColumnSchema column)
	{
		if (column.Name.EndsWith("TypeCode")) return column.Name;
		string type;
		switch (column.DataType)
		{
			case DbType.AnsiString: type= "string";break;
			case DbType.AnsiStringFixedLength: type= "string";break;
			case DbType.Binary: type= "byte[]";break;
			case DbType.Boolean: type= "bool";break;
			case DbType.Byte: type= "byte";break;
			case DbType.Currency: type= "decimal";break;
			case DbType.Date: type= "DateTime";break;
			case DbType.DateTime: type= "DateTime";break;
			case DbType.Decimal: type= "decimal";break;
			case DbType.Double: type= "double";break;
			case DbType.Guid: type= "Guid";break;
			case DbType.Int16: type= "short";break;
			case DbType.Int32: type= "int";break;
			case DbType.Int64: type= "long";break;
			case DbType.Object: type= "object";break;
			case DbType.SByte: type= "sbyte";break;
			case DbType.Single: type= "float";break;
			case DbType.String: type= "string";break;
			case DbType.StringFixedLength: type= "string";break;
			case DbType.Time: type= "TimeSpan";break;
			case DbType.UInt16: type= "ushort";break;
			case DbType.UInt32: type= "uint";break;
			case DbType.UInt64: type= "ulong";break;
			case DbType.VarNumeric: type= "decimal";break;
			default:
			{
				type= "__UNKNOWN__" + column.NativeType;
				break;
			}
		}
		if(column.AllowDBNull&&
			column.SystemType.IsValueType)
		{
			type=type+"?";
		}
		return type;
	}
开发者ID:cityjoy,项目名称:DapperCodeSmith,代码行数:43,代码来源:ToolsCodeTemplate.cs

示例9: GetConvertToNETType

 public static string GetConvertToNETType(ColumnSchema  column, string strExpression)
 {
     switch (column.NetDataType)
     {
         case "System.Int32":
             return "Convert.ToInt32(" + strExpression + ")";
         case "System.Byte":
             return "Convert.ToByte(" + strExpression + ")";
         case "System.Boolean":
             return "Convert.ToBoolean(" + strExpression + ")";
         case "System.Char":
             return "Convert.ToChar(" + strExpression + ")";
         case "System.DateTime":
             return "Convert.ToDateTime(" + strExpression + ")";
         case "System.Decimal":
             return "Convert.ToDecimal(" + strExpression + ")";
         case "System.Double":
             return "Convert.ToDouble(" + strExpression + ")";
         case "System.Int16":
             return "Convert.ToInt16(" + strExpression + ")";
         case "System.Int64":
             return "Convert.ToInt64(" + strExpression + ")";
         case "System.SByte":
             return "Convert.ToSByte(" + strExpression + ")";
         case "System.Single":
             return "Convert.ToSingle(" + strExpression + ")";
         case "System.TimeSpan":
             return "Convert.ToDateTime(" + strExpression + ")";
         case "System.UInt16":
             return "Convert.ToUInt16(" + strExpression + ")";
         case "System.UInt32":
             return "Convert.ToUInt32(" + strExpression + ")";
         case "System.UInt64":
             return "Convert.ToUInt64 (" + strExpression + ")";
         case "System.Guid":
             return "Convert.ToString(" + strExpression + ")";
         case "System.Byte[]":
             return "(Byte[])(" + strExpression + ")";
         default:
             return "Convert.ToString(" + strExpression + ")";
     }
 }
开发者ID:martinherr3,项目名称:medusa,代码行数:42,代码来源:Helper.cs

示例10: ExtractType

 private string ExtractType(ColumnSchema schema)
 {
     var rez = schema.DataType;
     if (!string.IsNullOrEmpty(schema.CharacterMaximumLength))
     {
         rez = rez + "(" + (schema.CharacterMaximumLength == "-1"
                                ? "max"
                                : schema.CharacterMaximumLength) + ")";
         return rez;
     }
     if (!string.IsNullOrEmpty(schema.NumericPrecision))
     {
         rez = rez + "(" + schema.NumericPrecision;
         if (!string.IsNullOrEmpty(schema.NumericScale))
         {
             rez = rez + "," + schema.NumericScale;
         }
         return rez + ")";
     }
     return rez;
 }
开发者ID:gmav,项目名称:SqlFu,代码行数:21,代码来源:SqlServerCompactModifiedColumnsWriter.cs

示例11: GetMemberVariableDefaultValue

 public string GetMemberVariableDefaultValue(ColumnSchema column)
 {
     switch (column.DataType)
     {
         case DbType.Guid:
         {
             return "Guid.Empty";
         }
         case DbType.AnsiString:
         case DbType.AnsiStringFixedLength:
         case DbType.String:
         case DbType.StringFixedLength:
         {
             return "String.Empty";
         }
         default:
         {
             return "";
         }
     }
 }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:21,代码来源:TypedDataSet.cst.cs

示例12: GetColumns

 public override IList<ColumnSchema> GetColumns(System.Data.Common.DbConnectionStringBuilder connectionstr, string tablename)
 {
     IList<ColumnSchema> list = null;
     using (MySqlConnection connection = new MySqlConnection(connectionstr.ConnectionString))
     {
         connection.Open();
         DataTable columns = connection.GetSchema(SqlClientMetaDataCollectionNames.Columns, new string[] { null, null, tablename, null });
         if (columns != null && columns.Rows.Count > 0)
         {
             list = new List<ColumnSchema>();
             DataView dv = columns.DefaultView;
             dv.Sort = "ORDINAL_POSITION asc";
             foreach (DataRowView table in dv)
             {
                 string name = string.Format("{0}({1})", table["COLUMN_NAME"], table["DATA_TYPE"]);
                 ColumnSchema column = new ColumnSchema(name);
                 list.Add(column);
             }
         }
     }
     return list;
 }
开发者ID:Tony-Liang,项目名称:Common,代码行数:22,代码来源:MySqlProvider.cs

示例13: GetConvert

 public string GetConvert(ColumnSchema column)
 {
     if (column.Name.EndsWith("TypeCode")) return column.Name;
     
     switch (column.DataType)
     {
         case DbType.AnsiString: return "Convert.ToString";
         case DbType.AnsiStringFixedLength: return "Convert.ToString";
         case DbType.Binary: return "Convert.ToByte";
         case DbType.Boolean: return "Convert.ToBoolean";
         case DbType.Byte: return "Convert.ToInt32";
         case DbType.Currency: return "Convert.ToDecimal";
         case DbType.Date: return "Convert.ToDateTime";
         case DbType.DateTime: return "Convert.ToDateTime";
         case DbType.Decimal: return "Convert.ToDecimal";
         case DbType.Double: return "Convert.ToDouble";
         case DbType.Guid: return "Convert.ToString";
         case DbType.Int16: return "Convert.ToInt16";
         case DbType.Int32: return "Convert.ToInt32";
         case DbType.Int64: return "Convert.ToInt64";
         case DbType.Object: return "Convert.ToString";
         case DbType.SByte: return "Convert.ToByte";
         case DbType.Single: return "Convert.ToInt32";
         case DbType.String: return "Convert.ToString";
         case DbType.StringFixedLength: return "Convert.ToString";
         case DbType.Time: return "Convert.DateTime";
         case DbType.UInt16: return "Convert.ToUInt16";
         case DbType.UInt32: return "Convert.ToUInt32";
         case DbType.UInt64: return "Convert.ToUInt64";
         case DbType.VarNumeric: return "Convert.ToDecimal";
         default:
         {
             return "__UNKNOWN__" + column.NativeType;
         }
     }
 }
开发者ID:cityjoy,项目名称:DapperCodeSmith,代码行数:36,代码来源:ToolsCodeTemplate.cs

示例14: GetCSharpConvert

        public static string GetCSharpConvert(ColumnSchema column, string placeholder)
        {
            if (column.Name.EndsWith("TypeCode")) return column.Name;

            switch (column.DataType)
            {
                case DbType.AnsiString: return placeholder;
                case DbType.AnsiStringFixedLength: return placeholder;
                //case DbType.Binary: return "byte []";
                case DbType.Boolean: return "Convert.ToBoolean(" + placeholder + ");";
                case DbType.Byte: return "Convert.ToByte(" + placeholder + ")";
                case DbType.Currency: return "Convert.ToDecimal(" + placeholder + ")";
                case DbType.Date: return placeholder;
                case DbType.DateTime: return placeholder;
                case DbType.Decimal: return "Convert.ToDecimal(" + placeholder + ")";
                case DbType.Double: return "Convert.ToDouble(" + placeholder + ")";
                case DbType.Guid: return placeholder;
                case DbType.Int16: return "Convert.ToInt16(" + placeholder + ")";
                case DbType.Int32: return "Convert.ToInt32(" + placeholder + ")";
                case DbType.Int64: return "Convert.ToInt64(" + placeholder + ")";
                case DbType.Object: return placeholder;
                case DbType.SByte: return "Convert.ToSByte(" + placeholder + ")";
                case DbType.Single: return "Convert.ToFloat(" + placeholder + ")";
                case DbType.String: return placeholder;
                case DbType.StringFixedLength: return placeholder;
                case DbType.Time: return "TimeSpan";
                case DbType.UInt16: return "Convert.ToUInt16(" + placeholder + ")";
                case DbType.UInt32: return "Convert.ToUInt32(" + placeholder + ")";
                case DbType.UInt64: return "Convert.ToUInt64(" + placeholder + ")";
                case DbType.VarNumeric: return "Convert.ToDecimal(" + placeholder + ")";
                default:
                    {
                        return "__UNKNOWN__" + column.NativeType;
                    }
            }
        }
开发者ID:smacinn,项目名称:CodeSmithHelper,代码行数:36,代码来源:CSharp.cs

示例15: GetCSharpVariableType

        public static string GetCSharpVariableType(ColumnSchema column)
        {
            if (column.Name.EndsWith("TypeCode")) return column.Name;

            switch (column.DataType)
            {
                case DbType.AnsiString: return "string";
                case DbType.AnsiStringFixedLength: return "string";
                case DbType.Binary: return "byte []";
                case DbType.Boolean: return "bool";
                case DbType.Byte: return "byte";
                case DbType.Currency: return "decimal";
                case DbType.Date: return "DateTime";
                case DbType.DateTime: return "DateTime";
                case DbType.Decimal: return "decimal";
                case DbType.Double: return "double";
                case DbType.Guid: return "Guid";
                case DbType.Int16: return "short";
                case DbType.Int32: return "int";
                case DbType.Int64: return "long";
                case DbType.Object: return "object";
                case DbType.SByte: return "sbyte";
                case DbType.Single: return "float";
                case DbType.String: return "string";
                case DbType.StringFixedLength: return "string";
                case DbType.Time: return "TimeSpan";
                case DbType.UInt16: return "ushort";
                case DbType.UInt32: return "uint";
                case DbType.UInt64: return "ulong";
                case DbType.VarNumeric: return "decimal";
                default:
                    {
                        return "__UNKNOWN__" + column.NativeType;
                    }
            }
        }
开发者ID:smacinn,项目名称:CodeSmithHelper,代码行数:36,代码来源:CSharp.cs


注:本文中的ColumnSchema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。