本文整理汇总了C#中NHibernate.Mapping.PersistentClass.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# PersistentClass.AddProperty方法的具体用法?C# PersistentClass.AddProperty怎么用?C# PersistentClass.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.PersistentClass
的用法示例。
在下文中一共展示了PersistentClass.AddProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindTimestamp
private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas)
{
if (timestampSchema == null)
return;
string propertyName = timestampSchema.name;
var simpleValue = new SimpleValue(table);
new ColumnsBinder(simpleValue, Mappings).Bind(timestampSchema.Columns, false,
() =>
new HbmColumn
{name = mappings.NamingStrategy.PropertyToColumnName(propertyName)});
if (!simpleValue.IsTypeSpecified)
{
switch (timestampSchema.source)
{
case HbmTimestampSource.Vm:
simpleValue.TypeName = NHibernateUtil.Timestamp.Name;
break;
case HbmTimestampSource.Db:
simpleValue.TypeName = NHibernateUtil.DbTimestamp.Name;
break;
default:
simpleValue.TypeName = NHibernateUtil.Timestamp.Name;
break;
}
}
var property = new Property(simpleValue);
BindProperty(timestampSchema, property, inheritedMetas);
// 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 == HbmTimestampUnsavedvalue.Null ? null : "undefined";
rootClass.Version = property;
rootClass.AddProperty(property);
}
示例2: BindProperties
private void BindProperties(PersistentClass pclass, IEnumerable<PropertyInfo> infos)
{
var table = pclass.Table;
foreach (var propertyInfo in infos) {
if (typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType) && propertyInfo.PropertyType != typeof(string))
continue;
// Bind a simple value property
IValue value = new SimpleValue(table);
BindColumn((SimpleValue) value, true, propertyInfo.Name);
Property property = CreateProperty(value, propertyInfo, pclass.ClassName);
// property.IsUpdateable = false;
pclass.AddProperty(property);
}
}
示例3: BindVersion
private void BindVersion(HbmVersion versionSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas)
{
if (versionSchema == null)
return;
string propertyName = versionSchema.name;
var simpleValue = new SimpleValue(table);
new TypeBinder(simpleValue, Mappings).Bind(versionSchema.type);
new ColumnsBinder(simpleValue, Mappings).Bind(versionSchema.Columns, false,
() =>
new HbmColumn
{name = mappings.NamingStrategy.PropertyToColumnName(propertyName)});
if (!simpleValue.IsTypeSpecified)
simpleValue.TypeName = NHibernateUtil.Int32.Name;
var property = new Property(simpleValue);
BindProperty(versionSchema, property, inheritedMetas);
// 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 = versionSchema.unsavedvalue;
rootClass.Version = property;
rootClass.AddProperty(property);
}
示例4: PropertiesFromXML
protected void PropertiesFromXML(XmlNode node, PersistentClass model)
{
Table table = model.Table;
foreach (XmlNode subnode in node.ChildNodes)
{
//I am only concerned with elements that are from the nhibernate namespace
if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS)
continue;
string name = subnode.LocalName; //.Name;
string propertyName = GetPropertyName(subnode);
IValue value = null;
CollectionBinder collectionBinder = new CollectionBinder(this);
if (collectionBinder.CanCreate(name))
{
Mapping.Collection collection = collectionBinder.Create(name, subnode, model.EntityName,
propertyName, model, model.MappedClass);
mappings.AddCollection(collection);
value = collection;
}
else if ("many-to-one".Equals(name))
{
value = new ManyToOne(table);
BindManyToOne(subnode, (ManyToOne) value, propertyName, true);
}
else if ("any".Equals(name))
{
value = new Any(table);
BindAny(subnode, (Any) value, true);
}
else if ("one-to-one".Equals(name))
{
value = new OneToOne(table, model);
BindOneToOne(subnode, (OneToOne) value);
}
else if ("property".Equals(name))
{
value = new SimpleValue(table);
BindSimpleValue(subnode, (SimpleValue) value, true, propertyName);
}
else if ("component".Equals(name) || "dynamic-component".Equals(name))
{
// NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
value = new Component(model);
BindComponent(subnode, (Component) value, reflectedClass, model.EntityName, propertyName, true);
}
else if ("join".Equals(name))
{
Join join = new Join();
join.PersistentClass = model;
BindJoin(subnode, join);
model.AddJoin(join);
}
else if ("subclass".Equals(name))
new SubclassBinder(this).HandleSubclass(model, subnode);
else if ("joined-subclass".Equals(name))
new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode);
else if ("union-subclass".Equals(name))
new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode);
else if ("filter".Equals(name))
ParseFilter(subnode, model);
if (value != null)
model.AddProperty(CreateProperty(value, propertyName, model.MappedClass, subnode));
}
}
示例5: BindProperty
protected virtual void BindProperty(PropertyMapping propertyMapping, IValue value, PersistentClass model)
{
var property = CreateProperty(model, value, propertyMapping.PropertyInfo);
model.AddProperty(property);
}
示例6: 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);
}
示例7: AddColumn
private static void AddColumn(PersistentClass mapping, string columnName, Type accessorType)
{
var typeName = DICT_TYPE_TO_NAME[accessorType];
bool isNullable = typeName[typeName.Length - 1] == '?';
if (isNullable)
typeName = typeName.Substring(0, typeName.Length - 1);
// String annotations can be null also
isNullable = isNullable || Equals(STRING_TYPE_NAME, typeName);
var column = new Column(columnName) {IsNullable = isNullable};
mapping.Table.AddColumn(column);
var value = new SimpleValue(mapping.Table) {TypeName = typeName};
value.AddColumn(column);
var property = new Property(value)
{
Name = columnName,
PropertyAccessorName = accessorType.AssemblyQualifiedName
};
mapping.AddProperty(property);
}
示例8: PropertiesFromXML
protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas, UniqueKey uniqueKey, bool mutable, bool nullable, bool naturalId)
{
string entityName = model.EntityName;
Table table = model.Table;
foreach (XmlNode subnode in node.ChildNodes)
{
//I am only concerned with elements that are from the nhibernate namespace
if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS)
continue;
string name = subnode.LocalName; //.Name;
string propertyName = GetPropertyName(subnode);
IValue value = null;
CollectionBinder collectionBinder = new CollectionBinder(this);
if (collectionBinder.CanCreate(name))
{
Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, propertyName, model,
model.MappedClass, inheritedMetas);
mappings.AddCollection(collection);
value = collection;
}
else if ("many-to-one".Equals(name))
{
value = new ManyToOne(table);
BindManyToOne(subnode, (ManyToOne) value, propertyName, true);
}
else if ("any".Equals(name))
{
value = new Any(table);
BindAny(subnode, (Any) value, true);
}
else if ("one-to-one".Equals(name))
{
value = new OneToOne(table, model);
BindOneToOne(subnode, (OneToOne) value);
}
else if ("property".Equals(name))
{
value = new SimpleValue(table);
BindSimpleValue(subnode, (SimpleValue) value, true, propertyName);
}
else if ("component".Equals(name) || "dynamic-component".Equals(name))
{
string subpath = StringHelper.Qualify(entityName, propertyName);
// NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
value = new Component(model);
BindComponent(subnode, (Component) value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas);
}
else if ("join".Equals(name))
{
Join join = new Join();
join.PersistentClass = model;
BindJoin(subnode, join, inheritedMetas);
model.AddJoin(join);
}
else if ("subclass".Equals(name))
new SubclassBinder(this).HandleSubclass(model, subnode, inheritedMetas);
else if ("joined-subclass".Equals(name))
new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, inheritedMetas);
else if ("union-subclass".Equals(name))
new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, inheritedMetas);
else if ("filter".Equals(name))
ParseFilter(subnode, model);
else if ("natural-id".Equals(name))
{
UniqueKey uk = new UniqueKey();
uk.Name = "_UniqueKey";
uk.Table = table;
//by default, natural-ids are "immutable" (constant)
bool mutableId = false;
if (subnode.Attributes["mutable"] != null)
{
mutableId = "true".Equals(subnode.Attributes["mutable"]);
}
PropertiesFromXML(subnode, model, inheritedMetas, uk, mutableId, false, true);
table.AddUniqueKey(uk);
}
if (value != null)
{
Property property = CreateProperty(value, propertyName, model.ClassName, subnode, inheritedMetas);
if (!mutable)
property.IsUpdateable = false;
if (naturalId)
property.IsNaturalIdentifier = true;
model.AddProperty(property);
if (uniqueKey != null)
uniqueKey.AddColumns(new SafetyEnumerable<Column>(property.ColumnIterator));
}
}
//.........这里部分代码省略.........