• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IModelInspector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IModelInspector的典型用法代码示例。如果您正苦于以下问题:C# IModelInspector类的具体用法?C# IModelInspector怎么用?C# IModelInspector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IModelInspector类属于命名空间,在下文中一共展示了IModelInspector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BeforeMappingCollectionConvention

        private void BeforeMappingCollectionConvention(IModelInspector inspector, PropertyPath member, ICollectionPropertiesMapper customizer)
        {
            if (inspector.IsManyToMany(member.LocalMember))
                customizer.Table(member.ManyToManyIntermediateTableName());

            customizer.Key(k => k.Column(DetermineKeyColumnName(inspector, member)));
        }
开发者ID:MatthewRudolph,项目名称:Airy,代码行数:7,代码来源:ModelMapperWithNamingConventions.cs


示例2: MemberReadOnlyAccessor

		protected virtual void MemberReadOnlyAccessor(IModelInspector modelInspector, PropertyPath member, IAccessorPropertyMapper propertyCustomizer)
		{
			if (MatchReadOnlyProperty(member.LocalMember))
			{
				propertyCustomizer.Access(Accessor.ReadOnly);
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:7,代码来源:ConventionModelMapper.cs


示例3: MapStringLengthFromAttribute

        public static void MapStringLengthFromAttribute(IModelInspector modelinspector, PropertyPath member, IPropertyMapper propertycustomizer)
        {
            var propertyInfo = member.LocalMember as PropertyInfo;
            if (propertyInfo == null || propertyInfo.PropertyType != typeof(string))
            {
                return;
            }

            var attributes = propertyInfo.GetCustomAttributes(true);
            var attribute = attributes.FirstOrDefault(x => x.GetType().Name.IndexOf("Length") > -1);
            if (attribute == null)
            {
                return;
            }
            int value = 0;
            var possiblePropertyNames = new[] { "MaximumLength", "Length", "Max", "MaxLength" };
            foreach (var name in possiblePropertyNames)
            {
                var attributeProperty = attribute.GetType().GetProperty(name);
                if (attributeProperty != null)
                {
                    value = (int)attributeProperty.GetValue(attribute, null);
                    break;
                }
            }

            if (value == 0)
            {
                throw new InvalidOperationException(
                    string.Format("could not get the length of property {0}", propertyInfo.Name));
            }

            propertycustomizer.Length(value);
        }
开发者ID:mellibo,项目名称:MappingByCodeConvention,代码行数:34,代码来源:PropertiesConvention.cs


示例4: OnBeforeMapProperty

 private void OnBeforeMapProperty(IModelInspector modelinspector, PropertyPath member, IPropertyMapper propertycustomizer)
 {
     if(member.LocalMember.Name == "Name")
     {
         propertycustomizer.Unique(true);
     }
 }
开发者ID:SaleemCB,项目名称:AzureSamples,代码行数:7,代码来源:SessionFactoryProvider.cs


示例5: ManyToManyConvention

 public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map)
 {
     map.ForeignKey(
         string.Format("fk_{0}_{1}",
                member.LocalMember.Name,
                member.GetContainerEntity(modelInspector).Name));
 }
开发者ID:yao-yi,项目名称:DNTProfiler,代码行数:7,代码来源:NamingConventions.cs


示例6: DetermineKeyColumnName

        private static string DetermineKeyColumnName(IModelInspector inspector, PropertyPath member)
        {
            var otherSideProperty = member.OneToManyOtherSideProperty();
            if (inspector.IsOneToMany(member.LocalMember) && otherSideProperty != null)
                return otherSideProperty.Name + ForeignKeyColumnPostfix;

            return member.Owner().Name + ForeignKeyColumnPostfix;
        }
开发者ID:MatthewRudolph,项目名称:Airy,代码行数:8,代码来源:ModelMapperWithNamingConventions.cs


示例7: MapStringAsVarchar

 public static void MapStringAsVarchar(IModelInspector modelInspector, PropertyPath member, IPropertyMapper propertyCustomizer)
 {
     var propertyInfo = member.LocalMember as PropertyInfo;
     if (propertyInfo != null && propertyInfo.PropertyType == typeof(string))
     {
         propertyCustomizer.Type(NHibernateUtil.AnsiString);
     }
 }
开发者ID:mellibo,项目名称:MappingByCodeConvention,代码行数:8,代码来源:PropertiesConvention.cs


示例8: GetContainerEntity

		public static System.Type GetContainerEntity(this PropertyPath propertyPath, IModelInspector domainInspector)
		{
			PropertyPath analizing = propertyPath;
			while (analizing.PreviousPath != null && !domainInspector.IsEntity(analizing.LocalMember.ReflectedType))
			{
				analizing = analizing.PreviousPath;
			}
			return analizing.LocalMember.ReflectedType;
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:9,代码来源:PropertyPathExtensions.cs


示例9: ReferenceConvention

 public static void ReferenceConvention(IModelInspector modelInspector, PropertyPath member, IManyToOneMapper map)
 {
     map.Column(k => k.Name(member.LocalMember.GetPropertyOrFieldType().Name + "Id"));
     map.ForeignKey(
         string.Format("fk_{0}_{1}",
                member.LocalMember.Name,
                member.GetContainerEntity(modelInspector).Name));
     map.Cascade(Cascade.All | Cascade.DeleteOrphans);
 }
开发者ID:yao-yi,项目名称:DNTProfiler,代码行数:9,代码来源:NamingConventions.cs


示例10: ForeignKey

        /// <summary>
        /// Returns the name of the foreign key in a relationship.
        /// </summary>
        /// <param name="inspector">The model inspector.</param>
        /// <param name="member">The entity property.</param>
        /// <returns>The name of the foreign key.</returns>
        public string ForeignKey(IModelInspector inspector, PropertyPath member, Type declaringType = null, Type idDeclaringType = null)
        {
            Requires.That(member, "member").IsNotNull();
            Requires.That(member.LocalMember, "member.LocalMember").IsNotNull();

            return ForeignKeyNameFormat.Formatted(Table(inspector, idDeclaringType ?? member.LocalMember.GetPropertyOrFieldType()),
                                              Table(inspector, declaringType ?? member.LocalMember.DeclaringType),
                                              Column(inspector, member, idDeclaringType));
        }
开发者ID:HackedByChinese,项目名称:NStack,代码行数:15,代码来源:DefaultNamingConvention.cs


示例11: ApplyDateTimeOffsetSplitTypeToDateTimeOffset

 /// <summary>
 /// Applies the <see cref="DateTimeOffsetSplitType"/> Composite user type to all <see cref="DateTimeOffset"/> fields in the mapping.
 /// </summary>
 /// <remarks>
 /// Allows the use of <see cref="DateTimeOffset"/> type with databases that do not natively support it.
 /// User: mapper.BeforeMapProperty += ModelMapperHelper.ApplyDateTimeOffsetSplitTypeToDateTimeOffset
 /// </remarks>
 public static void ApplyDateTimeOffsetSplitTypeToDateTimeOffset(IModelInspector inspector, PropertyPath property, IPropertyMapper mapper)
 {
     Type propertyType = property.LocalMember.GetPropertyOrFieldType();
     if (propertyType == typeof(DateTimeOffset) || propertyType == typeof(DateTimeOffset?))
     {
         mapper.Type(typeof(DateTimeOffsetSplitType), null);
         string columName = property.ToColumnName();
         mapper.Columns(n => n.Name(columName + "DateTime"), n => n.Name(columName + "Offset"));
     }
 }
开发者ID:MatthewRudolph,项目名称:Airy,代码行数:17,代码来源:ModelMapperHelper.cs


示例12: ConventionModelMapper

 private ConventionModelMapper(string tablePrefix, IModelInspector modelInspector, ICustomizersHolder customizerHolder)
     : base(modelInspector, modelInspector as IModelExplicitDeclarationsHolder, customizerHolder, new DefaultCandidatePersistentMembersProvider())
 {
     Conventions = new MappingConventions
     {
         TablePrefix = tablePrefix
     };
     CustomizersHolder = customizerHolder;
     AppendDefaultEvents();
 }
开发者ID:sigcms,项目名称:Seeger,代码行数:10,代码来源:ConventionModelMapper.cs


示例13: OneToManyConvention

 public static void OneToManyConvention(IModelInspector modelInspector, PropertyPath member, IBagPropertiesMapper map)
 {
     var inv = member.LocalMember.GetInverseProperty();
     if (inv == null)
     {
         map.Key(x => x.Column(member.GetContainerEntity(modelInspector).Name + "Id"));
         map.Cascade(Cascade.All | Cascade.DeleteOrphans);
         map.BatchSize(20);
         map.Inverse(true);
     }
 }
开发者ID:yao-yi,项目名称:DNTProfiler,代码行数:11,代码来源:NamingConventions.cs


示例14: IdBagTableName

 private void IdBagTableName(IModelInspector modelInspector, PropertyPath member, IIdBagPropertiesMapper propertyCustomizer)
 {
     if (member.LocalMember.IsComponentCollection(Mapper.ModelInspector))
     {
         propertyCustomizer.Table(member.GetRootMember().DeclaringType.Name + member.ToColumnName());
     }
     else
     {
         propertyCustomizer.Table(BidirectionAssociation.AnalizeManyToMany(member.LocalMember).ManyToManyTablename);
     }
 }
开发者ID:solyutor,项目名称:enhima,代码行数:11,代码来源:Idbag.cs


示例15: DicriminatorColumnNamedClass

        private void DicriminatorColumnNamedClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            if(DiscriminatorIsNotRequired(type)) return;

            classCustomizer.Discriminator(
                dm =>
                    {
                        dm.Column("Class");
                        dm.NotNullable(true);
                    });
        }
开发者ID:solyutor,项目名称:enhima,代码行数:11,代码来源:Class.cs


示例16: NameKeyColumn

        private void NameKeyColumn(IModelInspector modelinspector, PropertyPath member, IBagPropertiesMapper propertycustomizer)
        {
            var association = BidirectionAssociation.AnalyzeManyToOne(member);

            var columnName = association.IsBidirectional
                           ? association.ColumnNameOnCollectionSide
                           : member.GetRootMember().ReflectedType.Name + "Id";

            propertycustomizer.Key(keyMapper => keyMapper.Column(columnName));

            propertycustomizer.Inverse(association.IsBidirectional);
        }
开发者ID:solyutor,项目名称:enhima,代码行数:12,代码来源:Bag.cs


示例17: ComponentParentNoSetterToField

		protected virtual void ComponentParentNoSetterToField(IModelInspector modelInspector, PropertyPath member, IComponentAttributesMapper componentMapper)
		{
			System.Type componentType = member.LocalMember.GetPropertyOrFieldType();
			IEnumerable<MemberInfo> persistentProperties =
				MembersProvider.GetComponentMembers(componentType).Where(p => ModelInspector.IsPersistentProperty(p));

			MemberInfo parentReferenceProperty = GetComponentParentReferenceProperty(persistentProperties, member.LocalMember.ReflectedType);
			if (parentReferenceProperty != null && MatchNoSetterProperty(parentReferenceProperty))
			{
				componentMapper.Parent(parentReferenceProperty, cp => cp.Access(Accessor.NoSetter));
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:12,代码来源:ConventionModelMapper.cs


示例18: MapEnumAsString

        private static void MapEnumAsString(IModelInspector modelInspector, PropertyPath member, IPropertyMapper propertyCustomizer)
        {
            var propertyType = member.LocalMember.GetPropertyOrFieldType();

            if (propertyType.IsEnumOrNullableEnum() == false) return;

            var enumType = propertyType.IsEnum ? propertyType : propertyType.GetGenericArguments().Single();

            var type = typeof(EnumStringType<>).MakeGenericType(enumType);

            propertyCustomizer.Type(type, null);
        }
开发者ID:solyutor,项目名称:enhima,代码行数:12,代码来源:Property.cs


示例19: BeforeMapSet

		protected virtual new void BeforeMapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
		{
			if (modelInspector.IsManyToMany(member.LocalMember) == true)
			{
				propertyCustomizer.Key(x => x.Column(member.LocalMember.DeclaringType.Name + "_Id"));

				Type sourceType = member.LocalMember.DeclaringType;
				Type destinationType = member.LocalMember.GetPropertyOrFieldType().GetGenericArguments().First();
				String [] names = new Type[] { sourceType, destinationType }.Select(x => x.Name).OrderBy(x => x).ToArray();

				//set inverse on the relation of the alphabetically first entity name
				propertyCustomizer.Inverse(sourceType.Name == names.First());
				//set mapping table name from the entity names in alphabetical order
				propertyCustomizer.Table(String.Join("_", names));
			}
		}
开发者ID:rjperes,项目名称:DevelopmentWithADot.NHibernateConventions,代码行数:16,代码来源:ManyToManyConventionModelMapper.cs


示例20: IdBagHiloGenerator

        private void IdBagHiloGenerator(IModelInspector modelInspector, PropertyPath member, IIdBagPropertiesMapper propertyCustomizer)
        {
            var hiloRowName = member.LocalMember.IsComponentCollection(Mapper.ModelInspector)
                                  ? member.GetRootMember().DeclaringType.Name + member.ToColumnName()
                                  : BidirectionAssociation.AnalizeManyToMany(member.LocalMember).ManyToManyTablename;

            propertyCustomizer.Id(idMap =>
            {
                idMap.Generator(new EntityHighLowGeneratorDef(hiloRowName));

                idMap.Column("Id");
                idMap.Type((IIdentifierType)NHibernateUtil.Int64);
            });

            Mapper.AddHiLoScript(EntityHighLowGenerator.GetInsertFor(hiloRowName));
        }
开发者ID:solyutor,项目名称:enhima,代码行数:16,代码来源:Idbag.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IModelListView类代码示例发布时间:2022-05-24
下一篇:
C# IModelElement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap