本文整理汇总了C#中ClassMapping.AddPropertyMapping方法的典型用法代码示例。如果您正苦于以下问题:C# ClassMapping.AddPropertyMapping方法的具体用法?C# ClassMapping.AddPropertyMapping怎么用?C# ClassMapping.AddPropertyMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassMapping
的用法示例。
在下文中一共展示了ClassMapping.AddPropertyMapping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createMapping
public virtual ClassMapping<object> createMapping(Type type)
{
ClassMapping<object> mapping = new ClassMapping<object>();
// type
mapping.ClassType = type;
// table
LogicalTable logicalTable = new LogicalTable();
mapping.CorrespondingTable = logicalTable;
TableDefinition table = new TableDefinition();
Table tableAttr = AttributeUtils.getSingleAttribute<Table>(type);
if (tableAttr != null) {
table.Name = tableAttr.Name;
} else {
table.Name = generateTableName(type.Name);
}
logicalTable.Name = table.Name;
// all fields including id
foreach (FieldInfo field in getClassFields(type)) {
if (isFieldPersistent(field)) {
FieldMapping<object, object> fieldMapping = new FieldMapping<object, object>() {ClassField = field};
TableColumn column = new TableColumn();
logicalTable.AddColumn(column);
Column colAttr = AttributeUtils.getSingleAttribute<Column>(field);
if (colAttr != null) {
column.Name = colAttr.Name;
} else {
column.Name = field.Name;
}
fieldMapping.Column = column;
table.addColumn(column);
mapping.AddPropertyMapping (fieldMapping);
Id idAttr = AttributeUtils.getSingleAttribute<Id>(field);
if (idAttr != null) {
mapping.IdMapping = fieldMapping;
column.IsPrimaryKey = true;
fieldMapping.IsId = true;
}
}
}
return mapping;
}