本文整理汇总了C#中IPropertyMap.GetReferencedClassMap方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyMap.GetReferencedClassMap方法的具体用法?C# IPropertyMap.GetReferencedClassMap怎么用?C# IPropertyMap.GetReferencedClassMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyMap
的用法示例。
在下文中一共展示了IPropertyMap.GetReferencedClassMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyReference
private void VerifyReference(IPropertyMap propertyMap)
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
if (propertyMap.ReferenceType == ReferenceType.OneToOne || propertyMap.ReferenceType == ReferenceType.OneToMany)
{
if (propertyMap.IsCollection)
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyColumnIsForeignKey(propertyMap);
}
else if (propertyMap.ReferenceType == ReferenceType.ManyToOne)
{
if (!(propertyMap.IsCollection))
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyIDColumnIsForeignKey(propertyMap);
}
else if (propertyMap.ReferenceType == ReferenceType.ManyToMany)
{
if (!(propertyMap.IsCollection))
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyColumnIsForeignKey(propertyMap);
VerifyIDColumnIsForeignKey(propertyMap);
}
IClassMap referencedClassMap = propertyMap.GetReferencedClassMap() ;
if (referencedClassMap == null)
{
HandleVerifyException(propertyMap, "Reference type class not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Referenced class: '" + propertyMap.DataType + "')", "DataType"); // do not localize
}
else
{
if (referencedClassMap.ClassType == ClassType.Interface)
{
HandleVerifyException(propertyMap, "Persistent reference properties can not use interfaces as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
}
else if (referencedClassMap.ClassType == ClassType.Struct)
{
HandleVerifyException(propertyMap, "Persistent reference properties can not use structs as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
}
else if (referencedClassMap.ClassType == ClassType.Enum)
{
HandleVerifyException(propertyMap, "Reference type should be set to None for properties with enumeration types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "ReferenceType"); // do not localize
}
}
}
else
{
if (!(propertyMap.ReferenceType == ReferenceType.None))
{
HandleVerifyException(propertyMap, "Reference type must be set None for non-reference properties! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "DataType"); // do not localize
}
}
}
示例2: CreateColumnForProperty
//.........这里部分代码省略.........
columnMap.DataType = GetColumnTypeForProperty(propertyMap);
columnMap.Length = GetColumnLengthForProperty(propertyMap);
columnMap.Precision = GetColumnPrecisionForProperty(propertyMap);
columnMap.Scale = GetColumnScaleForProperty(propertyMap);
allowNulls = propertyMap.IsNullable;
if (propertyMap.IsIdentity)
{
allowNulls = false;
}
columnMap.AllowNulls = allowNulls;
if (propertyMap.IsIdentity)
{
columnMap.IsPrimaryKey = true;
columnMap.AllowNulls = false;
if (propertyMap.ReferenceType == ReferenceType.None)
{
if (columnMap.DataType == DbType.Int16 || columnMap.DataType == DbType.Int32 || columnMap.DataType == DbType.Int64)
{
if (propertyMap.ClassMap.GetIdentityPropertyMaps().Count == 1)
{
if (propertyMap.GetIsAssignedBySource())
{
columnMap.IsAutoIncrease = true;
columnMap.Seed = 1;
columnMap.Increment = 1;
}
}
}
}
}
if (!(propertyMap.ReferenceType == ReferenceType.None))
{
foreignKeyName = "FK_" + columnMap.TableMap.Name + "_" + columnMap.Name;
refClassMap = propertyMap.GetReferencedClassMap();
if (!(refClassMap == null))
{
foreach (IPropertyMap idProp in refClassMap.GetIdentityPropertyMaps())
{
if (cnt > 0)
{
if (idProp.Column.Length > 0)
{
name = idProp.Column;
}
else
{
name = GetColumnNameForProperty(idProp);
}
foreignKeyName += "_" + name;
}
}
}
primColName = "";
if (refClassMap.TypeColumn.Length > 0)
{
primColName = refClassMap.TypeColumn;
}
else
{
if (!(refClassMap.InheritanceType == InheritanceType.None))
{
primColName = GetTypeColumnNameForClass(refClassMap);
}
}
if (primColName.Length > 0)
{
示例3: GetRootPrimaryKey
/// <summary>
/// Gets the root primary key, follows all references (foreign keys).
/// </summary>
/// <param name="propertyMap">The property map.</param>
/// <returns></returns>
public static IPropertyMap GetRootPrimaryKey(IPropertyMap propertyMap)
{
int count = 0;
IPropertyMap key = propertyMap;
while (key.ReferenceType != ReferenceType.None)
{
key = ClassUtility.GetPrimaryKey(propertyMap.GetReferencedClassMap());
if (++count >= 10000)
{
return key;
throw new Exception("Ring reference? count: " + count + "; property: " + propertyMap.Name + "; class: " + propertyMap.ClassMap.Name);
}
}
return key;
}