本文整理汇总了C#中IModelInspector.FindPersistentId方法的典型用法代码示例。如果您正苦于以下问题:C# IModelInspector.FindPersistentId方法的具体用法?C# IModelInspector.FindPersistentId怎么用?C# IModelInspector.FindPersistentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModelInspector
的用法示例。
在下文中一共展示了IModelInspector.FindPersistentId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Column
/// <summary>
/// Returns the name of the table column for an entity's property.
/// </summary>
/// <param name="inspector">The model inspector.</param>
/// <param name="member">The entity property.</param>
/// <param name="declaringType"> </param>
/// <returns>The name of the table column.</returns>
public string Column(IModelInspector inspector, PropertyPath member, Type declaringType = null)
{
Requires.That(member, "member").IsNotNull();
Requires.That(member.LocalMember, "member.LocalMember").IsNotNull();
var localName = member.LocalMember.Name.Underscore();
if (declaringType != null)
{
return KeyColumnFormat.Formatted(declaringType.Name.Underscore(), localName);
}
var type = member.LocalMember.GetPropertyOrFieldType();
if (inspector.IsEntity(type)) // is a foreign key
{
var id = inspector.FindPersistentId(type);
if (id != null) return KeyColumnFormat.Formatted(localName, Column(inspector, id));
}
return localName;
}
示例2: KeyColumn
/// <summary>
/// Returns the name of a key column.
/// </summary>
/// <param name="inspector">The model inspector.</param>
/// <param name="member"></param>
/// <param name="declaringType"> </param>
/// <returns></returns>
public string KeyColumn(IModelInspector inspector, PropertyPath member, Type declaringType = null)
{
Requires.That(member, "member").IsNotNull();
Requires.That(member.LocalMember, "member.LocalMember").IsNotNull();
var type = declaringType ?? member.LocalMember.DeclaringType;
var localName = type.Name.Underscore();
var id = inspector.FindPersistentId(type);
return KeyColumnFormat.Formatted(localName, id.LocalMember.Name.Underscore());
}