本文整理匯總了C#中ClassMap.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# ClassMap.Add方法的具體用法?C# ClassMap.Add怎麽用?C# ClassMap.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ClassMap
的用法示例。
在下文中一共展示了ClassMap.Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddComponent
protected virtual void AddComponent(ClassMap map, Property property, ComponentType componentType)
{
// Assuming componentType.PropertyNames match up to property.ColumnIterator...
for (var propertyIndex = 0; propertyIndex < componentType.PropertyNames.Length; propertyIndex++)
{
var columnCount = componentType.Subtypes[propertyIndex].GetColumnSpan(_mapping);
if (columnCount != 1)
throw new NotSupportedException(
string.Format(
"The multi-column property {0}.{1}.{2} is not supported. Each property must map to a single column",
property.PersistentClass.ClassName,
property.Name,
componentType.PropertyNames[propertyIndex]));
var propertyPath = property.Name + "." + componentType.PropertyNames[propertyIndex];
var columnName = property.ColumnIterator.ElementAt(propertyIndex).Text;
map.Add(propertyPath, columnName);
}
}
示例2: AddProperty
protected virtual void AddProperty(ClassMap map, Property property)
{
if (property == null) return;
if (property.Type.IsComponentType)
{
AddComponent(map, property, (ComponentType) property.Type);
return;
}
var name = property.Name;
if (property.ColumnSpan != 1)
throw new NotSupportedException(
string.Format(
"The multi-column property {0}.{1} is not supported. Each property must map to a single column",
property.PersistentClass.ClassName,
property.Name));
var column = property.ColumnIterator.Single().Text;
map.Add(name, column);
}