本文整理汇总了C#中IModelInspector.IsPersistentId方法的典型用法代码示例。如果您正苦于以下问题:C# IModelInspector.IsPersistentId方法的具体用法?C# IModelInspector.IsPersistentId怎么用?C# IModelInspector.IsPersistentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModelInspector
的用法示例。
在下文中一共展示了IModelInspector.IsPersistentId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NoPoidGuid
protected virtual void NoPoidGuid(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
{
MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(mi => modelInspector.IsPersistentId(mi));
if (!ReferenceEquals(null, poidPropertyOrField))
{
return;
}
classCustomizer.Id(null, idm=> idm.Generator(Generators.Guid));
}
示例2: ApplyIdMappings
private void ApplyIdMappings(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
{
var member = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(m => modelInspector.IsPersistentId(m));
if (member != null)
{
var idAttr = member.GetCustomAttributes(typeof(IdAttribute), false).OfType<IdAttribute>().FirstOrDefault();
// If IdAttribute is not specified for persistent id property, then use the default id mapping strategy
if (idAttr == null)
{
idAttr = new IdAttribute();
}
var context = new MappingContext(modelInspector, Conventions);
foreach (var mapper in _attributeMapperFactory.GetIdAttributeMappers(idAttr))
{
mapper.ApplyMapping(idAttr, member, type, classCustomizer, context);
}
}
}
示例3: TryMapComponent
private void TryMapComponent(IModelInspector modelInspector, PropertyPath member, IPropertyMapper propertyCustomizer)
{
if (modelInspector.IsComponent(member.LocalMember.DeclaringType)
&& !modelInspector.IsPersistentId(member.PreviousPath.LocalMember))
{
propertyCustomizer.Column(member.PreviousPath.LocalMember.Name + "_" + member.LocalMember.Name);
}
}
示例4: OnMapperOnBeforeMapClass
/// <summary>
/// Sets the mapper to use:
/// 1) a native generator for int primary keys
/// 2) a Generators.GuidComb generator for Guid primary keys
/// 3) a string length of 128 for string primary keys
/// </summary>
private void OnMapperOnBeforeMapClass(IModelInspector inspector, Type type, IClassAttributesMapper customizer)
{
foreach (var p in type.GetProperties())
{
if (inspector.IsPersistentId(p))
{
var idType = p.PropertyType;
if (idType == typeof(int))
{
customizer.Id(x => x.Generator(Generators.Native));
}
else if (idType == typeof(string))
{
var customAttributes = p.GetCustomAttributes(false);
StringLengthAttribute stringlengthAttribute = (StringLengthAttribute)customAttributes.FirstOrDefault(x => x.GetType() == typeof(StringLengthAttribute));
int length = DefaltStringIdLength;
if (stringlengthAttribute != null && stringlengthAttribute.MaximumLength > 0)
{
length = stringlengthAttribute.MaximumLength;
}
customizer.Id(x => x.Length(length));
}
else if (idType == typeof(Guid))
{
customizer.Id(x => { x.Generator(Generators.GuidComb); });
}
}
}
}