本文整理汇总了C#中NHibernate.Mapping.Column类的典型用法代码示例。如果您正苦于以下问题:C# Column类的具体用法?C# Column怎么用?C# Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于NHibernate.Mapping命名空间,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MigrationColumn
public MigrationColumn(Column column, MigrationColumnType type)
{
Name = column.Name;
IsNullable = column.IsNullable;
Type = type;
IsPrimaryKey = false;
}
示例2: UnmatchingColumns
public void UnmatchingColumns()
{
Table primaryTable = new Table("pktable");
primaryTable.PrimaryKey = new PrimaryKey();
SimpleValue sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column pkColumn = new Column("pk_column");
pkColumn.Value = sv;
primaryTable.PrimaryKey.AddColumn(pkColumn);
Table fkTable = new Table("fktable");
ForeignKey fk = new ForeignKey();
sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column fkColumn1 = new Column("col1");
fkColumn1.Value = sv;
sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column fkColumn2 = new Column("col2");
fkColumn2.Value = sv;
fk.AddColumn(fkColumn1);
fk.AddColumn(fkColumn2);
fk.Table = fkTable;
fk.ReferencedTable = primaryTable;
Assert.Throws<FKUnmatchingColumnsException>(() => fk.AlignColumns());
}
示例3: SelectMigrationColumn
private MigrationColumn SelectMigrationColumn(Column column)
{
if (column.Value.Type.ReturnedClass == typeof(Guid))
return new GuidMigrationColumn(column);
if (column.Value.Type.ReturnedClass == typeof(decimal))
return new DecimalMigrationColumn(column);
if (column.Value.Type.ReturnedClass == typeof(string))
return new StringMigrationColumn(column);
if (column.Value.Type.ReturnedClass == typeof(DateTime))
return new DateTimeMigrationColumn(column);
if (column.Value.Type.ReturnedClass == typeof(bool))
return new BoolMigrationColumn(column);
if (column.Value.Type.ReturnedClass == typeof(short))
return new ShortMigrationColumn(column);
//TODO Blob
// if (column.Value.Type.ReturnedClass.IsEnum || column.Value.Type.ReturnedClass == typeof(int))
return new IntegerMigrationColumn(column);
}
示例4: BindColumn
private static void BindColumn(Column column, bool isNullable)
{
column.IsNullable = isNullable;
column.IsUnique = false;
column.CheckConstraint = string.Empty;
column.SqlType = null;
}
示例5: AddColumn
/// <summary>
///
/// </summary>
/// <param name="column"></param>
public virtual void AddColumn( Column column )
{
if( !columns.Contains( column ) )
{
columns.Add( column );
}
}
示例6: UnmatchingColumns
public void UnmatchingColumns()
{
Table primaryTable = new Table();
primaryTable.Name = "pktable";
primaryTable.PrimaryKey = new PrimaryKey();
Column pkColumn = new Column( NHibernateUtil.Int16, 0 );
pkColumn.Name = "pk_column";
primaryTable.PrimaryKey.AddColumn( pkColumn );
Table fkTable = new Table();
fkTable.Name = "fktable";
ForeignKey fk = new ForeignKey();
Column fkColumn1 = new Column( NHibernateUtil.Int16, 0 );
fkColumn1.Name = "col1";
Column fkColumn2 = new Column( NHibernateUtil.Int16, 0 );
fkColumn2.Name = "col2";
fk.AddColumn( fkColumn1 );
fk.AddColumn( fkColumn2 );
fk.Table = fkTable;
fk.ReferencedTable = primaryTable;
}
示例7: BindColumn
private static void BindColumn(Column model, bool isNullable)
{
model.IsNullable = isNullable;
model.IsUnique = false;
model.CheckConstraint = string.Empty;
model.SqlType = null;
}
示例8: remapGetDateDefaultValues
static void remapGetDateDefaultValues(Column column)
{
if (string.Compare(column.SqlType, "datetime", StringComparison.OrdinalIgnoreCase) != 0 &&
string.Compare(column.DefaultValue, "getdate()", StringComparison.OrdinalIgnoreCase) != 0)
return;
column.DefaultValue = "CURRENT_TIMESTAMP";
}
示例9: BindIndex
private static void BindIndex(string indexAttribute, Table table, Column column)
{
if (indexAttribute != null && table != null)
{
var tokens = indexAttribute.Split(',');
System.Array.ForEach(tokens, t => table.GetOrCreateIndex(t.Trim()).AddColumn(column));
}
}
示例10: BindUniqueKey
private static void BindUniqueKey(string uniqueKeyAttribute, Table table, Column column)
{
if (uniqueKeyAttribute != null && table != null)
{
var tokens = uniqueKeyAttribute.Split(',');
System.Array.ForEach(tokens, t => table.GetOrCreateUniqueKey(t.Trim()).AddColumn(column));
}
}
示例11: Create
public MigrationColumn Create(Column column)
{
var result = SelectMigrationColumn(column);
result.OwnerTable = OwnerTable;
return result;
}
示例12: YesNoSqlType
public void YesNoSqlType()
{
SimpleValue sv = new SimpleValue();
sv.TypeName = NHibernateUtil.YesNo.Name;
Column column = new Column();
column.Value = sv;
string type = column.GetSqlType(_dialect, null);
Assert.AreEqual("CHAR(1)", type);
}
示例13: BindIndex
protected static void BindIndex(string indexAttribute, Table table, Column column)
{
if (indexAttribute != null && table != null)
{
StringTokenizer tokens = new StringTokenizer(indexAttribute, ", ");
foreach (string token in tokens)
table.GetOrCreateIndex(token).AddColumn(column);
}
}
示例14: StringSqlType
public void StringSqlType()
{
Column column = new Column(NHibernateUtil.String, 0);
Assert.AreEqual("NVARCHAR(255)", column.GetSqlType(_dialect, null));
column.Length = 100;
Assert.AreEqual("NVARCHAR(100)", column.GetSqlType(_dialect, null));
}
示例15: BindColumn
private static void BindColumn(HbmDiscriminator discriminatorSchema, Column column)
{
if (discriminatorSchema.length != null)
column.Length = int.Parse(discriminatorSchema.length);
column.IsNullable = !discriminatorSchema.notnull;
column.IsUnique = false;
column.CheckConstraint = string.Empty;
column.SqlType = null;
}