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


C# IPropertyMap.GetReferencedClassMap方法代码示例

本文整理汇总了C#中IPropertyMap.GetReferencedClassMap方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyMap.GetReferencedClassMap方法的具体用法?C# IPropertyMap.GetReferencedClassMap怎么用?C# IPropertyMap.GetReferencedClassMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPropertyMap的用法示例。


在下文中一共展示了IPropertyMap.GetReferencedClassMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyReference

 private void VerifyReference(IPropertyMap propertyMap)
 {
     if (propertyMap.ReferenceType != ReferenceType.None)
     {
         if (propertyMap.ReferenceType == ReferenceType.OneToOne || propertyMap.ReferenceType == ReferenceType.OneToMany)
         {
             if (propertyMap.IsCollection)
             {
                 HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
             }
             VerifyColumnIsForeignKey(propertyMap);
         }
         else if (propertyMap.ReferenceType == ReferenceType.ManyToOne)
         {
             if (!(propertyMap.IsCollection))
             {
                 HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
             }
             VerifyIDColumnIsForeignKey(propertyMap);
         }
         else if (propertyMap.ReferenceType == ReferenceType.ManyToMany)
         {
             if (!(propertyMap.IsCollection))
             {
                 HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
             }
             VerifyColumnIsForeignKey(propertyMap);
             VerifyIDColumnIsForeignKey(propertyMap);
         }
         IClassMap referencedClassMap = propertyMap.GetReferencedClassMap() ;
         if (referencedClassMap == null)
         {
             HandleVerifyException(propertyMap, "Reference type class not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Referenced class: '" + propertyMap.DataType + "')", "DataType"); // do not localize
         }
         else
         {
             if (referencedClassMap.ClassType == ClassType.Interface)
             {
                 HandleVerifyException(propertyMap, "Persistent reference properties can not use interfaces as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
             }
             else if (referencedClassMap.ClassType == ClassType.Struct)
             {
                 HandleVerifyException(propertyMap, "Persistent reference properties can not use structs as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
             }
             else if (referencedClassMap.ClassType == ClassType.Enum)
             {
                 HandleVerifyException(propertyMap, "Reference type should be set to None for properties with enumeration types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "ReferenceType"); // do not localize
             }
         }
     }
     else
     {
         if (!(propertyMap.ReferenceType == ReferenceType.None))
         {
             HandleVerifyException(propertyMap, "Reference type must be set None for non-reference properties! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "DataType"); // do not localize
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:58,代码来源:MapVerificationVisitor.cs

示例2: CreateColumnForProperty


//.........这里部分代码省略.........
     columnMap.DataType = GetColumnTypeForProperty(propertyMap);
     columnMap.Length = GetColumnLengthForProperty(propertyMap);
     columnMap.Precision = GetColumnPrecisionForProperty(propertyMap);
     columnMap.Scale = GetColumnScaleForProperty(propertyMap);
     allowNulls = propertyMap.IsNullable;
     if (propertyMap.IsIdentity)
     {
         allowNulls = false;
     }
     columnMap.AllowNulls = allowNulls;
     if (propertyMap.IsIdentity)
     {
         columnMap.IsPrimaryKey = true;
         columnMap.AllowNulls = false;
         if (propertyMap.ReferenceType == ReferenceType.None)
         {
             if (columnMap.DataType == DbType.Int16 || columnMap.DataType == DbType.Int32 || columnMap.DataType == DbType.Int64)
             {
                 if (propertyMap.ClassMap.GetIdentityPropertyMaps().Count == 1)
                 {
                     if (propertyMap.GetIsAssignedBySource())
                     {
                         columnMap.IsAutoIncrease = true;
                         columnMap.Seed = 1;
                         columnMap.Increment = 1;
                     }
                 }
             }
         }
     }
     if (!(propertyMap.ReferenceType == ReferenceType.None))
     {
         foreignKeyName = "FK_" + columnMap.TableMap.Name + "_" + columnMap.Name;
         refClassMap = propertyMap.GetReferencedClassMap();
         if (!(refClassMap == null))
         {
             foreach (IPropertyMap idProp in refClassMap.GetIdentityPropertyMaps())
             {
                 if (cnt > 0)
                 {
                     if (idProp.Column.Length > 0)
                     {
                         name = idProp.Column;
                     }
                     else
                     {
                         name = GetColumnNameForProperty(idProp);
                     }
                     foreignKeyName += "_" + name;
                 }
             }
         }
         primColName = "";
         if (refClassMap.TypeColumn.Length > 0)
         {
             primColName = refClassMap.TypeColumn;
         }
         else
         {
             if (!(refClassMap.InheritanceType == InheritanceType.None))
             {
                 primColName = GetTypeColumnNameForClass(refClassMap);
             }
         }
         if (primColName.Length > 0)
         {
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:67,代码来源:ClassesToTablesTransformer.cs

示例3: GetRootPrimaryKey

		/// <summary>
		/// Gets the root primary key, follows all references (foreign keys).
		/// </summary>
		/// <param name="propertyMap">The property map.</param>
		/// <returns></returns>
		public static IPropertyMap GetRootPrimaryKey(IPropertyMap propertyMap)
		{
			int count = 0;
			IPropertyMap key = propertyMap;
			while (key.ReferenceType != ReferenceType.None)
			{
				key = ClassUtility.GetPrimaryKey(propertyMap.GetReferencedClassMap());
				if (++count >= 10000)
				{
					return key;
					throw new Exception("Ring reference? count: " + count + "; property: " + propertyMap.Name + "; class: " + propertyMap.ClassMap.Name);
				}
			}
			return key;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:20,代码来源:ClassUtility.cs


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