当前位置: 首页>>代码示例>>C#>>正文


C# IModelInspector.IsPersistentId方法代码示例

本文整理汇总了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));
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:9,代码来源:ConventionModelMapper.cs

示例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);
                }
            }
        }
开发者ID:sigcms,项目名称:Seeger,代码行数:22,代码来源:ConventionModelMapper.cs

示例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);
     }
 }
开发者ID:sigcms,项目名称:Seeger,代码行数:8,代码来源:ConventionModelMapper.cs

示例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); });
             }
         }
     }
 }
开发者ID:MatthewRudolph,项目名称:Airy,代码行数:35,代码来源:DefaultModelMapper.cs


注:本文中的IModelInspector.IsPersistentId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。