本文整理汇总了C#中IModelInspector.IsTablePerClassHierarchy方法的典型用法代码示例。如果您正苦于以下问题:C# IModelInspector.IsTablePerClassHierarchy方法的具体用法?C# IModelInspector.IsTablePerClassHierarchy怎么用?C# IModelInspector.IsTablePerClassHierarchy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModelInspector
的用法示例。
在下文中一共展示了IModelInspector.IsTablePerClassHierarchy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnBeforeMapClass
protected override void OnBeforeMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
{
classCustomizer.DynamicInsert(DynamicInsert);
classCustomizer.DynamicUpdate(DynamicUpdate);
classCustomizer.Table(GetTableName(modelInspector, type));
classCustomizer.Id(
m =>
{
m.Column(GetKeyColumnName(modelInspector, type, false));
m.Generator(Generators.HighLow);
});
if (modelInspector.IsTablePerClassHierarchy(type))
{
classCustomizer.Discriminator(m => m.Column(GetDiscriminatorColumnName(modelInspector, type)));
classCustomizer.DiscriminatorValue(GetDiscriminatorValue(modelInspector, type));
}
MemberInfo[] versionProperties = VersionProperties(modelInspector, type).ToArray();
if (versionProperties.Length == 1)
{
classCustomizer.Version(versionProperties[0], m => m.Column(GetVersionColumnName(modelInspector, type)));
}
}
示例2: GetColumnName
protected virtual string GetColumnName(IModelInspector modelInspector, PropertyPath member)
{
string defaultColumnName = member.ToColumnName();
string columnPrefix = null;
string columnName = null;
Type currentType = member.LocalMember.ReflectedType;
bool walkToParent = modelInspector.IsTablePerClassHierarchy(currentType);
while (currentType != null && currentType != typeof(object))
{
ModelMetaData modelMetaData;
if (ModelMetaDatasByType.TryGetValue(currentType, out modelMetaData))
{
columnPrefix = modelMetaData.ColumnPrefix;
modelMetaData.ColumnNames.TryGetValue(defaultColumnName, out columnName);
break;
}
currentType = walkToParent ? currentType.BaseType : null;
}
string result = string.Concat(columnPrefix, columnName ?? GetIdentifier(defaultColumnName));
return result;
}