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


C# IModelInspector类代码示例

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


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


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