本文整理汇总了C#中NHibernate.Cfg.MappingSchema.HbmId类的典型用法代码示例。如果您正苦于以下问题:C# HbmId类的具体用法?C# HbmId怎么用?C# HbmId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HbmId类属于NHibernate.Cfg.MappingSchema命名空间,在下文中一共展示了HbmId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSetUnsavedValue
public void CanSetUnsavedValue()
{
var hbmId = new HbmId();
var mapper = new IdMapper(null, hbmId);
mapper.UnsavedValue(-1);
hbmId.unsavedvalue.Should().Be("-1");
}
示例2: CanSetColumnName
public void CanSetColumnName()
{
var hbmId = new HbmId();
var mapper = new IdMapper(null, hbmId);
mapper.Column("MyName");
hbmId.Columns.Single().name.Should().Be("MyName");
}
示例3: CreateIdentifierProperty
private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, SimpleValue id)
{
if (idSchema.name != null)
{
string access = idSchema.access ?? mappings.DefaultAccess;
id.SetTypeUsingReflection(rootClass.MappedClass.AssemblyQualifiedName, idSchema.name, access);
Mapping.Property property = new Mapping.Property(id);
property.Name = idSchema.name;
if (property.Value.Type == null)
throw new MappingException("could not determine a property type for: " + property.Name);
property.PropertyAccessorName = idSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
property.IsUpdateable = true;
property.IsInsertable = true;
property.IsOptimisticLocked = true;
property.Generation = PropertyGeneration.Never;
property.MetaAttributes = GetMetas(idSchema);
rootClass.IdentifierProperty = property;
LogMappedProperty(property);
}
}
示例4: 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);
}
}
示例5: CanSetGeneratorForeign
public void CanSetGeneratorForeign()
{
var hbmId = new HbmId();
new IdMapper(hbmId).Generator(Generators.Foreign<MyClass>(mc => mc.OneToOne));
[email protected]().Be.EqualTo("foreign");
hbmId.generator.param.Should().Not.Be.Null().And.Have.Count.EqualTo(1);
hbmId.generator.param.Single().Satisfy(p => p.name == "property" && p.GetText() == "OneToOne");
}
示例6: 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;
}
示例7: Should_get_null_given_column_is_null
public void Should_get_null_given_column_is_null()
{
HbmId id = new HbmId
{
column = null
};
bool? result = id.CanBeNull();
result.ShouldBeNull();
}
示例8: CanSetGeneratorWithParameters
public void CanSetGeneratorWithParameters()
{
var hbmId = new HbmId();
new IdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" }));
[email protected]().Be.EqualTo("hilo");
hbmId.generator.param.Should().Have.Count.EqualTo(2);
hbmId.generator.param.Select(p => p.name).Should().Have.SameValuesAs("max_low", "where");
hbmId.generator.param.Select(p => p.GetText()).Should().Have.SameValuesAs("99", "TableName");
}
示例9: CanSetGeneratorWithParameters
public void CanSetGeneratorWithParameters()
{
var hbmId = new HbmId();
new IdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" }));
Assert.That([email protected], Is.EqualTo("hilo"));
Assert.That(hbmId.generator.param, Has.Length.EqualTo(2));
Assert.That(hbmId.generator.param.Select(p => p.name), Is.EquivalentTo(new [] {"max_low", "where"}));
Assert.That(hbmId.generator.param.Select(p => p.GetText()), Is.EquivalentTo(new [] {"99", "TableName"}));
}
示例10: CanSetGeneratorForeign
public void CanSetGeneratorForeign()
{
var hbmId = new HbmId();
new IdMapper(hbmId).Generator(Generators.Foreign<MyClass>(mc => mc.OneToOne));
Assert.That([email protected], Is.EqualTo("foreign"));
Assert.That(hbmId.generator.param, Is.Not.Null.And.Length.EqualTo(1));
var p = hbmId.generator.param.Single();
Assert.That(p.GetText(), Is.EqualTo("OneToOne"));
Assert.That(p.name, Is.EqualTo("property"));
}
示例11: AddColumns
private void AddColumns(HbmId idSchema, SimpleValue id)
{
if (idSchema.column1 != null)
AddColumnFromAttribute(idSchema, id);
else
AddColumnsFromList(idSchema, id);
if (id.ColumnSpan == 0)
AddDefaultColumn(idSchema, id);
}
示例12: BindUnsavedValue
private static void BindUnsavedValue(HbmId idSchema, SimpleValue id)
{
if (idSchema.unsavedvalue != null)
id.NullValue = idSchema.unsavedvalue;
else if (id.IdentifierGeneratorStrategy == "assigned")
// TODO: H3 has id.setNullValue("undefined") here, but NH doesn't (yet) allow "undefined"
// for id unsaved-value, so we use "null" here
id.NullValue = "null";
else
id.NullValue = null;
}
示例13: CreateColumn
private static Column CreateColumn(HbmId idSchema)
{
Column column = new Column();
if (idSchema.length != null)
column.Length = int.Parse(idSchema.length);
column.IsNullable = false;
column.IsUnique = false;
column.CheckConstraint = string.Empty;
column.SqlType = null;
return column;
}
示例14: BindId
public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
{
if (idSchema != null)
{
SimpleValue id = CreateIdentifier(idSchema, rootClass, table);
AddColumns(idSchema, id);
CreateIdentifierProperty(idSchema, rootClass, id);
VerifiyIdTypeIsValid(id, rootClass.MappedClass.Name);
BindGenerator(idSchema, id);
id.Table.SetIdentifierValue(id);
BindUnsavedValue(idSchema, id);
}
}
示例15: Should_get_null_given_column_notnullSpecified_is_false
public void Should_get_null_given_column_notnullSpecified_is_false()
{
HbmId id = new HbmId
{
column = new[]
{
new HbmColumn
{
notnullSpecified = false
}
}
};
bool? result = id.CanBeNull();
result.ShouldBeNull();
}