本文整理汇总了C#中NHibernate.Mapping.Table类的典型用法代码示例。如果您正苦于以下问题:C# Table类的具体用法?C# Table怎么用?C# Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于NHibernate.Mapping命名空间,在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TablesUniquelyNamedOnlyWithinThread
public void TablesUniquelyNamedOnlyWithinThread()
{
var uniqueIntegerList = new System.Collections.Concurrent.ConcurrentBag<int>();
var method = new ThreadStart(() =>
{
Table tbl1 = new Table();
Table tbl2 = new Table();
// Store these values for later comparison
uniqueIntegerList.Add(tbl1.UniqueInteger);
uniqueIntegerList.Add(tbl2.UniqueInteger);
// Ensure that within a thread we have unique integers
Assert.AreEqual(tbl1.UniqueInteger + 1, tbl2.UniqueInteger);
});
var thread1 = new CrossThreadTestRunner(method);
var thread2 = new CrossThreadTestRunner(method);
thread1.Start();
thread2.Start();
thread1.Join();
thread2.Join();
// There should in total be 4 tables, but only two distinct identifiers.
Assert.AreEqual(4, uniqueIntegerList.Count);
Assert.AreEqual(2, uniqueIntegerList.Distinct().Count());
}
示例2: AuditTable
public AuditTable(Table dataTable,
INamingStrategy namingStrategy,
IAuditColumnSource auditColumnSource)
{
_auditTable = BuildAuditTable(dataTable,
namingStrategy, auditColumnSource);
}
示例3: TablesUniquelyNamed
public void TablesUniquelyNamed()
{
Table tbl1 = new Table();
Table tbl2 = new Table();
Assert.AreEqual(tbl1.UniqueInteger + 1, tbl2.UniqueInteger);
}
示例4: AuditTable
public AuditTable(Table dataTable,
INamingStrategy namingStrategy,
IAuditColumnSource auditColumnSource)
{
this.auditColumnSource = auditColumnSource;
auditTable = BuildAuditTable(dataTable, namingStrategy);
}
示例5: IndexInfo
internal IndexInfo(Table table, Index index)
{
_name = MakeName("IX_", table.Name, index.ColumnIterator);
_columns = CollectionUtils.Map<Column, string>(
index.ColumnIterator,
delegate(Column column) { return column.Name; });
}
示例6: GetAuditColumns
public IEnumerable<AuditColumn> GetAuditColumns(Table dataTable)
{
var userStamp = new AuditColumn()
{
Name = "AuditUser",
SqlType = "sysname",
Length = 50,
IsNullable = false,
IncludeInPrimaryKey = true,
ValueFunction = delegate(TriggerActions action)
{
return "system_user";
}
};
var timeStamp = new AuditColumn()
{
Name = "AuditTimestamp",
Value = new SimpleValue()
{
TypeName = NHibernateUtil.DateTime.Name
},
IsNullable = false,
IncludeInPrimaryKey = true,
ValueFunction = delegate(TriggerActions action)
{
return "getdate()";
}
};
var operation = new AuditColumn()
{
Name = "AuditOperation",
Value = new SimpleValue()
{
TypeName = NHibernateUtil.AnsiChar.Name
},
Length = 1,
IsNullable = false,
IncludeInPrimaryKey = false,
ValueFunction = delegate(TriggerActions action)
{
switch (action)
{
case TriggerActions.INSERT:
return "'I'";
case TriggerActions.UPDATE:
return "'U'";
case TriggerActions.DELETE:
return "'D'";
default:
throw new ArgumentOutOfRangeException("action");
}
}
};
return new AuditColumn[] {
userStamp, timeStamp, operation
};
}
示例7: BindTimestamp
private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table)
{
if (timestampSchema == null)
return;
string propertyName = timestampSchema.name;
SimpleValue simpleValue = new SimpleValue(table);
BindColumns(timestampSchema, simpleValue, propertyName);
if (!simpleValue.IsTypeSpecified)
simpleValue.TypeName = NHibernateUtil.Timestamp.Name;
Mapping.Property property = new Mapping.Property(simpleValue);
BindProperty(timestampSchema, property);
// for version properties marked as being generated, make sure they are "always"
// generated; "insert" is invalid. This is dis-allowed by the schema, but just to make
// sure...
if (property.Generation == PropertyGeneration.Insert)
throw new MappingException("'generated' attribute cannot be 'insert' for versioning property");
simpleValue.NullValue = timestampSchema.unsavedvalue;
rootClass.Version = property;
rootClass.AddProperty(property);
}
示例8: QuotedTableNameWithoutSchemaWithSqlLite
public void QuotedTableNameWithoutSchemaWithSqlLite()
{
Table tbl = new Table();
tbl.Name = "`name`";
Assert.AreEqual("\"name\"", tbl.GetQualifiedName(dialect));
}
示例9: QuotedTableNameWithSqlLite
public void QuotedTableNameWithSqlLite()
{
Table tbl = new Table();
tbl.Name = "`Group`";
Assert.AreEqual("\"Group\"", tbl.GetQualifiedName(dialect));
}
示例10: BuildSqlDropIndexString
public static string BuildSqlDropIndexString(Dialect.Dialect dialect, Table table, string name, string defaultCatalog, string defaultSchema)
{
string ifExists = dialect.GetIfExistsDropConstraint(table, name);
string drop = string.Format("drop index {0}", StringHelper.Qualify(table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), name));
string end = dialect.GetIfExistsDropConstraintEnd(table, name);
return ifExists + Environment.NewLine + drop + Environment.NewLine + end;
}
示例11: BindId
public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
{
if (idSchema != null)
{
var id = new SimpleValue(table);
new TypeBinder(id, Mappings).Bind(idSchema.Type);
rootClass.Identifier = id;
Func<HbmColumn> defaultColumn = () => new HbmColumn
{
name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
length = idSchema.length
};
new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);
CreateIdentifierProperty(idSchema, rootClass, id);
VerifiyIdTypeIsValid(id.Type, rootClass.EntityName);
new IdGeneratorBinder(Mappings).BindGenerator(id, GetIdGenerator(idSchema));
id.Table.SetIdentifierValue(id);
BindUnsavedValue(idSchema, id);
}
}
示例12: 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;
}
示例13: 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());
}
示例14: 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));
}
}
示例15: CreateIdentifier
private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
{
SimpleValue iv = new SimpleValue(table);
iv.TypeName = idSchema.type;
rootClass.Identifier = iv;
return iv;
}