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


C# IPropertyMap.GetColumnMap方法代码示例

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


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

示例1: GetPropertyColumn

		public virtual SqlColumnAlias GetPropertyColumn(IPropertyMap propertyMap, object hash) 
		{	
			if (hash == null) { hash = propertyMap; }
			SqlTableAlias tbl = sqlEmitter.GetTableAlias(propertyMap.MustGetTableMap(), hash)  ;

            IColumnMap columnMap = propertyMap.GetColumnMap();

            return tbl.GetSqlColumnAlias(columnMap);
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:9,代码来源:PropertyPathTraverser.cs

示例2: GenerateProperty

		/// <summary>
		/// Generates the property.
		/// </summary>
		/// <param name="file">The file.</param>
		/// <param name="property">The property.</param>
		/// <param name="isReadOnly">if set to <c>true</c> the readonly property is generated.</param>
		public static void GenerateProperty(StreamWriter file, IPropertyMap property, bool isReadOnly)
		{
			string fieldType = ConvertColumnTypeToCsType(property.GetColumnMap().DataType);
			string fieldName = GetFieldName(property);

			file.WriteLine("\t\tpublic " + fieldType + " " + property.Name);
			file.WriteLine("\t\t{");
			file.WriteLine("\t\t\tget { return " + fieldName + "; }");
			if (!isReadOnly)
			{
				file.WriteLine("\t\t\tset { " + fieldName + " = value; }");
			}
			file.WriteLine("\t\t}");
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:20,代码来源:ClassUtility.cs

示例3: GetDeleteOptimisticConcurrencyBehavior

		public virtual OptimisticConcurrencyBehaviorType GetDeleteOptimisticConcurrencyBehavior(OptimisticConcurrencyBehaviorType optimisticConcurrencyBehavior, IPropertyMap propertyMap)
		{
			IColumnMap columnMap = null;
			if (optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
			{
				if (this.Context.OptimisticConcurrencyMode == OptimisticConcurrencyMode.Disabled)
				{
					optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
				}
				else
				{
					optimisticConcurrencyBehavior = propertyMap.DeleteOptimisticConcurrencyBehavior;
					if (optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
					{
						optimisticConcurrencyBehavior = propertyMap.ClassMap.DeleteOptimisticConcurrencyBehavior;
						if (optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
						{
							optimisticConcurrencyBehavior = propertyMap.ClassMap.DomainMap.DeleteOptimisticConcurrencyBehavior;
							if (optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
							{
								optimisticConcurrencyBehavior = m_DeleteOptimisticConcurrencyBehavior;
							}
						}
					}					
				}
			}
			if (optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
			{
				columnMap = propertyMap.GetColumnMap();
				if (columnMap != null)
				{
					if (columnMap.DataType == DbType.AnsiString || columnMap.DataType == DbType.AnsiStringFixedLength || columnMap.DataType == DbType.String || columnMap.DataType == DbType.StringFixedLength)
					{
						if (columnMap.Precision == 0 || columnMap.Precision >= 4000)
						{
							optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
						}
						else
						{
							optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.IncludeWhenLoaded;
						}
					}
					else if (columnMap.DataType == DbType.Binary || columnMap.DataType == DbType.Object)
					{
						optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
					}
					else
					{
						optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.IncludeWhenLoaded;
					}
				}
			}
			else
			{
				if (!(optimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.Disabled))
				{
					if (propertyMap.DeleteOptimisticConcurrencyBehavior == OptimisticConcurrencyBehaviorType.DefaultBehavior)
					{
						columnMap = propertyMap.GetColumnMap();
						if (columnMap != null)
						{
							if (columnMap.DataType == DbType.AnsiString || columnMap.DataType == DbType.AnsiStringFixedLength || columnMap.DataType == DbType.String || columnMap.DataType == DbType.StringFixedLength)
							{
								if (columnMap.Precision == 0 || columnMap.Precision >= 4000)
								{
									optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
								}
							}
							else if (columnMap.DataType == DbType.Binary || columnMap.DataType == DbType.Object)
							{
								optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
							}
						}
					}
				}
			}
			if (columnMap == null)
			{
				columnMap = propertyMap.GetColumnMap();
			}
			if (columnMap != null)
			{
				if (columnMap.DataType == DbType.Binary || columnMap.DataType == DbType.Object)
				{
					optimisticConcurrencyBehavior = OptimisticConcurrencyBehaviorType.Disabled;
				}
			}
			return optimisticConcurrencyBehavior;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:89,代码来源:PersistenceManager.cs

示例4: ManageReferenceValue

		//if value is a list, values in list come in the same order as columns are returned from propertymap.refClassMap.GetIdentityCols! garantueed order !
		//type column value must have been extracted from list in advance and should be passed to discriminator param
		public virtual object ManageReferenceValue(object obj, IPropertyMap propertyMap, object value, object discriminator)
		{
			IClassMap refClassMap;
			IPropertyMap mapToId;
			bool isIdentity = false;
			if (!(propertyMap.ReferenceType == ReferenceType.None))
			{
				if (value != null)
				{
					string identity = "";
					refClassMap = propertyMap.MustGetReferencedClassMap();
					if (discriminator != null)
					{
						try
						{
							discriminator = discriminator.ToString() ;
						} 
						catch { discriminator = ""; }						
						refClassMap = refClassMap.GetSubClassWithTypeValue((string) discriminator);
						if (refClassMap == null)
							throw new NPersistException("Could not find class map with type value '" + (string) discriminator + "'");
					}
					mapToId = refClassMap.MustGetPropertyMapForColumnMap(propertyMap.GetColumnMap().MustGetPrimaryKeyColumnMap());
					if (mapToId.IsIdentity)
					{
						isIdentity = true;
						IList valueAsList = value as IList;
						if (valueAsList == null)
							identity = Convert.ToString(value);
						else
						{
							string separator = refClassMap.GetIdentitySeparator();

                            if (separator == "")
                            {
                                separator = "|";
                            }

							StringBuilder identityBuilder = new StringBuilder() ;
							foreach (object valueItem in valueAsList)
								identityBuilder.Append(Convert.ToString(valueItem) + separator) ;
							identityBuilder.Length -= separator.Length;

							identity = identityBuilder.ToString(); 
						}
					}
					if (isIdentity)
					{
					    return this.Context.GetObjectById(identity, this.Context.AssemblyManager.MustGetTypeFromClassMap(refClassMap), true);
					}
					else
						return this.Context.GetObjectByKey(mapToId.Name, Convert.ToString(value), obj.GetType().GetProperty(propertyMap.Name).PropertyType);
				}
			}
			return value;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:58,代码来源:PersistenceManager.cs

示例5: ValidateDatabaseDateRange

        private void ValidateDatabaseDateRange(object obj, IPropertyMap propertyMap, IList exceptions)
        {
            if (propertyMap.Column.Length > 0)
            {
                IObjectManager om = this.Context.ObjectManager;
                IColumnMap columnMap = propertyMap.GetColumnMap() ;
                if (columnMap != null)
                {
                    if (columnMap.DataType.Equals(DbType.DateTime) ||  columnMap.DataType.Equals(DbType.Time) || columnMap.DataType.Equals(DbType.Date))
                    {
                        if (!(om.GetNullValueStatus(obj, propertyMap.Name)))
                        {
                            ISourceMap sourceMap = propertyMap.GetSourceMap();
                            if (sourceMap != null)
                            {
                                object rawValue = om.GetPropertyValue(obj, propertyMap.Name);
                                if (rawValue == null )
                                {
                                    //all ok
                                }
                                else
                                {
                                    DateTime value = (DateTime)rawValue;
                                    if (sourceMap.SourceType == SourceType.MSSqlServer)
                                    {
                                        DateTime minDate = new DateTime(1753, 1, 1, 0, 0, 0);
                                        if (value < minDate)
                                        {
                                            string template = "Validation error in object {0}.{1} , property {2}: " + Environment.NewLine + "Sql server can not handle date/time values lower than 1753-01-01 00:00:00";
                                            string result = String.Format(
                                                template,
                                                propertyMap.ClassMap.Name,
                                                this.Context.ObjectManager.GetObjectKeyOrIdentity(obj),
                                                propertyMap.Name);

                                            HandleException(obj, propertyMap.Name, exceptions, new ValidationException(result), minDate, value, value);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:45,代码来源:ObjectValidator.cs

示例6: GetPropertyColumnAlias

 public virtual SqlColumnAlias GetPropertyColumnAlias(SqlTableAlias tableAlias, IPropertyMap propertyMap, string propertyPath, string suggestion)
 {
     return sqlEmitter.GetColumnAlias(tableAlias, propertyMap.GetColumnMap(), propertyPath, GetAliasSuggestionFromPropertyPath(propertyPath, suggestion))  ;
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:4,代码来源:PropertyPathTraverser.cs

示例7: VerifyColumns

 private void VerifyColumns(IPropertyMap propertyMap)
 {
     bool ok;
     if (propertyMap.SourceProperty.Length > 0)
     {
         if (propertyMap.GetSourcePropertyMap() == null)
         {
             HandleVerifyException(propertyMap, "Source property not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Source property: '" + propertyMap.SourceProperty + "')", "SourceProperty"); // do not localize
         }
     }
     else
     {
         if (propertyMap.Column.Length < 1)
         {
             ok = false;
             if (propertyMap.IsCollection && !(propertyMap.ReferenceType == ReferenceType.None))
             {
                 if (propertyMap.ReferenceType == ReferenceType.ManyToOne)
                 {
                     ok = true;
                 }
             }
             if (!(ok))
             {
                 HandleVerifyException(propertyMap, "Column name must not be empty! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "')", "Column"); // do not localize
             }
         }
         else
         {
             if (propertyMap.GetColumnMap() == null)
             {
                 HandleVerifyException(propertyMap, "Column not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Column: '" + propertyMap.Column + "')", "Column"); // do not localize
             }
         }
         if (propertyMap.IdColumn.Length > 0)
         {
             if (propertyMap.GetIdColumnMap() == null)
             {
                 HandleVerifyException(propertyMap, "ID Column not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', ID Column: '" + propertyMap.IdColumn + "')", "IdColumn"); // do not localize
             }
         }
         VerifyAdditionalColumns(propertyMap);
         VerifyAdditionalIDColumns(propertyMap);
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:45,代码来源:MapVerificationVisitor.cs

示例8: VerifyColumnIsForeignKey

 protected virtual void VerifyColumnIsForeignKey(IPropertyMap propertyMap)
 {
     if (!(this.checkOrmMappings))
     {
         return;
     }
     IColumnMap colMap;
     colMap = propertyMap.GetColumnMap();
     if (colMap != null)
     {
         if (!(colMap.IsForeignKey))
         {
             if (!(propertyMap.ReferenceType == ReferenceType.OneToOne) && propertyMap.IsSlave)
             {
                 HandleVerifyException(propertyMap, propertyMap.ReferenceType.ToString() + " reference property column must be marked as foreign key! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Column: '" + propertyMap.Column + "')", "Column"); // do not localize
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:19,代码来源:MapVerificationVisitor.cs

示例9: VerifyPropertySpecialBehavior

 private void VerifyPropertySpecialBehavior(IPropertyMap propertyMap)
 {
     IColumnMap colMap;
     if (propertyMap.OnCreateBehavior == PropertySpecialBehaviorType.Increase)
     {
         colMap = propertyMap.GetColumnMap();
         if (colMap != null)
         {
             if (colMap.DataType == DbType.Byte || colMap.DataType == DbType.Decimal || colMap.DataType == DbType.Double || colMap.DataType == DbType.Int16 || colMap.DataType == DbType.Int32 || colMap.DataType == DbType.Int64 || colMap.DataType == DbType.SByte || colMap.DataType == DbType.Single || colMap.DataType == DbType.UInt16 || colMap.DataType == DbType.UInt32 || colMap.DataType == DbType.UInt64 || colMap.DataType == DbType.VarNumeric)
             {
             }
             else
             {
                 HandleVerifyException(propertyMap, "Special property behavior 'Increase' may only be applied to properties mapping to numeric columns! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "')", "OnCreateBehavior"); // do not localize
             }
         }
     }
     else if (propertyMap.OnCreateBehavior == PropertySpecialBehaviorType.SetDateTime)
     {
         colMap = propertyMap.GetColumnMap();
         if (colMap != null)
         {
             if (colMap.DataType == DbType.Date || colMap.DataType == DbType.DateTime || colMap.DataType == DbType.Time)
             {
             }
             else
             {
                 HandleVerifyException(propertyMap, "Special property behavior 'SetDateTime' may only be applied to properties mapping to DateTime columns! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "')", "OnCreateBehavior"); // do not localize
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:32,代码来源:MapVerificationVisitor.cs

示例10: GetSelectManyManyPropertyStatement

		protected virtual string GetSelectManyManyPropertyStatement(object obj, IPropertyMap propertyMap, IList idColumns, IList typeColumns, Hashtable hashPropertyColumnMap, IList parameters)
		{
			IColumnMap columnMap;
			IClassMap classMap;
			IPropertyMap refPropertyMap;
			ITableMap tableMap;
			ITableMap joinTableMap;
			string colName;
			IObjectManager om;
			IColumnMap idColumnMap;
			IPropertyMap myPropertyMap;
			IColumnMap myColumnMap;
			ITableMap myTableMap;
			IColumnMap colColumnMap;
			IColumnMap forColumnMap;
			ITableMap forTableMap;
			IColumnMap addColumnMap;
			IColumnMap addIdColumnMap;
			IColumnMap addMyColumnMap;
			ITableMap addMyTableMap;
			IColumnMap typeColumnMap;
			IPropertyMap orderByMap;
			string paramName = "";
			classMap = propertyMap.MustGetReferencedClassMap();

			tableMap = classMap.MustGetTableMap();
			SqlSelectStatement select = new SqlSelectStatement(tableMap.SourceMap) ; 
			SqlTableAlias table = select.GetSqlTableAlias(tableMap);

			joinTableMap = propertyMap.MustGetTableMap();
			SqlTableAlias joinTable = select.GetSqlTableAlias(joinTableMap);

			idColumnMap = propertyMap.GetIdColumnMap();
			SqlColumnAlias idColumn = joinTable.GetSqlColumnAlias(idColumnMap);

			myTableMap = idColumnMap.MustGetPrimaryKeyTableMap();
			myColumnMap = idColumnMap.MustGetPrimaryKeyColumnMap();
			if (myTableMap == null)
				throw new MappingException("TableMap '" + idColumnMap.PrimaryKeyTable + "' Not Found!"); // do not localize
			if (myColumnMap == null)
				throw new MappingException("ColumnMap '" + idColumnMap.PrimaryKeyColumn + "' Not Found!"); // do not localize
			SqlTableAlias myTable;

			colColumnMap = propertyMap.GetColumnMap();
			forTableMap = colColumnMap.MustGetPrimaryKeyTableMap();
			forColumnMap = colColumnMap.MustGetPrimaryKeyColumnMap();
			if (forTableMap == null)
				throw new MappingException("TableMap '" + idColumnMap.PrimaryKeyTable + "' Not Found!"); // do not localize
			if (forColumnMap == null)
				throw new MappingException("ColumnMap '" + idColumnMap.PrimaryKeyColumn + "' Not Found!"); // do not localize
			SqlTableAlias forTable = select.GetSqlTableAlias(forTableMap);
			SqlColumnAlias forColumn = forTable.GetSqlColumnAlias(forColumnMap);
			SqlColumnAlias colColumn = joinTable.GetSqlColumnAlias(colColumnMap);

			orderByMap = propertyMap.GetOrderByPropertyMap();

			foreach (IPropertyMap iRefPropertyMap in classMap.GetPrimaryPropertyMaps())
			{
				refPropertyMap = iRefPropertyMap;
				if (!((refPropertyMap.IsCollection || (refPropertyMap.ReferenceType != ReferenceType.None && !(refPropertyMap.IsIdentity)))))
				{
					IColumnMap refColumnMap = refPropertyMap.GetColumnMap();
					SqlColumnAlias refColumn = select.GetSqlColumnAlias(refColumnMap);
					colName = refColumnMap.Name;
					if (refPropertyMap.IsIdentity)
						idColumns.Add(colName);

					if (!(refPropertyMap.LazyLoad))
					{
						select.SqlSelectClause.AddSqlAliasSelectListItem(refColumn);

						hashPropertyColumnMap[refPropertyMap.Name] = colName;
						if (refPropertyMap == orderByMap)
							select.SqlOrderByClause.AddSqlOrderByItem(refColumn);
					}
				}
			}
			typeColumnMap = classMap.GetTypeColumnMap();
			if (typeColumnMap != null)
			{
				typeColumns.Add(typeColumnMap.Name);
				SqlColumnAlias typeColumn = select.GetSqlColumnAlias(typeColumnMap);
				select.SqlSelectClause.AddSqlAliasSelectListItem(typeColumn);
			}
			select.SqlFromClause.AddSqlAliasTableSource(table);
			select.SqlFromClause.AddSqlAliasTableSource(joinTable);

			//if (tableMap.SourceMap.Schema.ToLower(CultureInfo.InvariantCulture) == myTableMap.SourceMap.Schema.ToLower(CultureInfo.InvariantCulture) && tableMap.Name.ToLower(CultureInfo.InvariantCulture) == myTableMap.Name.ToLower(CultureInfo.InvariantCulture))
			if (tableMap == myTableMap)
				myTable = select.GetSqlTableAlias(myTableMap, "NPersistSelfRefTable");
			else
				myTable = select.GetSqlTableAlias(myTableMap);

			SqlColumnAlias myColumn = myTable.GetSqlColumnAlias(myColumnMap);

			select.SqlFromClause.AddSqlAliasTableSource(myTable);

			SqlSearchCondition search = select.SqlWhereClause.GetNextSqlSearchCondition();
			search.GetSqlComparePredicate(forColumn, SqlCompareOperatorType.Equals,  colColumn);

//.........这里部分代码省略.........
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:101,代码来源:SqlEngineBase.cs

示例11: GetSelectSingleReferencePropertyStatement

		//Mats : Fixed non-primary ref prop bug by improving One-One backref identification
		protected virtual string GetSelectSingleReferencePropertyStatement(object obj, IPropertyMap propertyMap, IList idColumns, IList typeColumns, Hashtable hashPropertyColumnMap, IList parameters)
		{
			IColumnMap columnMap;
			IClassMap classMap;
			IPropertyMap refPropertyMap;
			ITableMap tableMap;
			IPropertyMap myPropertyMap;
			string colName;
			IColumnMap theColumnMap;
			IColumnMap forColumnMap;
			ITableMap forTableMap;
			IColumnMap addColumnMap;
			IColumnMap addForColumnMap;
			ITableMap addForTableMap;
			IColumnMap typeColumnMap;
			IDomainMap domainMap;
			bool isBackRef = false;
			string paramName = "";
			classMap = propertyMap.MustGetReferencedClassMap();
			if (propertyMap.ReferenceType == ReferenceType.OneToOne)
			{
				columnMap = propertyMap.GetColumnMap();
				if (columnMap != null)
					if (columnMap.TableMap == propertyMap.MustGetReferencedClassMap().MustGetTableMap())
						if (columnMap.IsPrimaryKey)
							isBackRef = true;
				columnMap = null;
			}

			
			SqlSelectStatement select; 
			SqlTableAlias table;
			SqlColumnAlias theColumn;
			SqlTableAlias forTable;
			SqlColumnAlias forColumn;

			if (isBackRef)
			{
				tableMap = propertyMap.ClassMap.MustGetTableMap();

				select = new SqlSelectStatement(tableMap.SourceMap) ; 
				table = select.GetSqlTableAlias(tableMap);


				//select.SqlSelectClause.AddSqlAliasSelectListItem(column);
				//select.SqlFromClause.AddSqlAliasTableSource(table);

				theColumnMap = propertyMap.GetIdColumnMap();
				//theColumn = table.GetSqlColumnAlias(theColumnMap);

				forTableMap = theColumnMap.TableMap;

				forColumnMap = theColumnMap;
				theColumnMap = forColumnMap.MustGetPrimaryKeyColumnMap();
				if (forTableMap == null)
					throw new MappingException("TableMap '" + theColumnMap.PrimaryKeyTable + "' Not Found!"); // do not localize
				if (forColumnMap == null)
					throw new MappingException("ColumnMap '" + theColumnMap.PrimaryKeyColumn + "' Not Found!"); // do not localize

				forTable = select.GetSqlTableAlias(forTableMap);
				forColumn = forTable.GetSqlColumnAlias(forColumnMap);
			}
			else
			{
				tableMap = propertyMap.MustGetTableMap();
				
				select = new SqlSelectStatement(tableMap.SourceMap) ; 
				table = select.GetSqlTableAlias(tableMap);

				theColumnMap = propertyMap.GetColumnMap();
				//theColumn = table.GetSqlColumnAlias(theColumnMap);

				forTableMap = theColumnMap.MustGetPrimaryKeyTableMap();
				forColumnMap = theColumnMap.MustGetPrimaryKeyColumnMap();
				if (forTableMap == null)
					throw new MappingException("TableMap '" + theColumnMap.PrimaryKeyTable + "' Not Found!"); // do not localize
				if (forColumnMap == null)
					throw new MappingException("ColumnMap '" + theColumnMap.PrimaryKeyColumn + "' Not Found!"); // do not localize

				forTable = select.GetSqlTableAlias(forTableMap);
				forColumn = forTable.GetSqlColumnAlias(forColumnMap);
			}

			IObjectManager om;
			foreach (IPropertyMap iRefPropertyMap in classMap.GetPrimaryPropertyMaps())
			{
				refPropertyMap = iRefPropertyMap;
				if (!(propertyMap.LazyLoad))
				{
					if (!((refPropertyMap.IsCollection || (refPropertyMap.ReferenceType != ReferenceType.None && !(refPropertyMap.IsIdentity)))))
					{
						IColumnMap refColumnMap = refPropertyMap.GetColumnMap();
						SqlColumnAlias refColumn = forTable.GetSqlColumnAlias(refColumnMap);
						colName = refColumnMap.Name;
						if (refPropertyMap.IsIdentity)
							idColumns.Add(colName);

						if (!(refPropertyMap.LazyLoad))
						{
//.........这里部分代码省略.........
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:101,代码来源:SqlEngineBase.cs

示例12: GetInsertCollectionValueStatement

		protected virtual string GetInsertCollectionValueStatement(object obj, IPropertyMap propertyMap, object value, IList parameters)
		{
			IClassMap classMap;
			IColumnMap columnMap;
			IColumnMap idColumnMap;
			IPropertyMap idPropertyMap;
			ITableMap tableMap;
			IObjectManager om = m_SqlEngineManager.Context.ObjectManager;
			string paramName;
			classMap = propertyMap.ClassMap;
			tableMap = propertyMap.MustGetTableMap();

			SqlInsertStatement insert = new SqlInsertStatement(tableMap.SourceMap);
			SqlTableAlias table = insert.GetSqlTableAlias(tableMap);

			insert.SqlInsertClause.SqlTable = table.SqlTable;

			idColumnMap = propertyMap.GetIdColumnMap();
			idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());
			SqlColumnAlias idColumn = table.GetSqlColumnAlias(idColumnMap);

			paramName = GetParameterName(idPropertyMap);
			SqlParameter param = AddSqlParameter(insert, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap);
			insert.AddSqlColumnAndValue(idColumn, param);
			foreach (IColumnMap iIdColumnMap in propertyMap.GetAdditionalIdColumnMaps())
			{
				idColumnMap = iIdColumnMap;
				idColumn = table.GetSqlColumnAlias(idColumnMap);

				paramName = GetParameterName(propertyMap, idColumnMap);

				if (!(classMap.GetTypeColumnMap() == null && classMap.GetTypeColumnMap() == idColumnMap.MustGetPrimaryKeyColumnMap()))
					param = AddSqlParameter(insert, parameters, paramName, obj, null, classMap.TypeValue, idColumnMap, true);
				else
				{
					idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());					
					param = AddSqlParameter(insert, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap);
				}

				insert.AddSqlColumnAndValue(idColumn, param);

			}
			columnMap = propertyMap.GetColumnMap();
			SqlColumnAlias column = table.GetSqlColumnAlias(columnMap);
			paramName = GetParameterName(propertyMap, columnMap);
			param = AddSqlParameter(insert, parameters, paramName, obj, propertyMap, value, columnMap, true);
			insert.AddSqlColumnAndValue(column, param);

			foreach (IColumnMap iColumnMap in propertyMap.GetAdditionalColumnMaps())
			{
				columnMap = iColumnMap;
				column = table.GetSqlColumnAlias(columnMap);
				paramName = GetParameterName(propertyMap, columnMap);
				param = AddSqlParameter(insert, parameters, paramName, obj, propertyMap, value, columnMap, true);
				insert.AddSqlColumnAndValue(column, param);
			}
			return GenerateSql(insert);
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:58,代码来源:SqlEngineBase.cs

示例13: GetRemoveCollectionValueStatement

		protected virtual string GetRemoveCollectionValueStatement(object obj, IPropertyMap propertyMap, object value, IList parameters)
		{
			IClassMap classMap;
			IColumnMap columnMap;
			IColumnMap idColumnMap;
			IPropertyMap idPropertyMap;
			ITableMap tableMap;
			string paramName = "";
			IObjectManager om = m_SqlEngineManager.Context.ObjectManager;
			classMap = propertyMap.ClassMap;
			tableMap = propertyMap.MustGetTableMap();

			
			SqlDeleteStatement delete = new SqlDeleteStatement(tableMap.SourceMap) ; 
			SqlTableAlias table = delete.GetSqlTableAlias(tableMap);

			delete.SqlFromClause.AddSqlAliasTableSource(table);

			idColumnMap = propertyMap.GetIdColumnMap();
			idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());
			SqlColumnAlias idColumn = table.GetSqlColumnAlias(idColumnMap);

			paramName = GetParameterName(idPropertyMap);
			SqlParameter param = AddSqlParameter(delete, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap, true);

			SqlSearchCondition search = delete.SqlWhereClause.GetNextSqlSearchCondition();
			search.GetSqlComparePredicate(idColumn, SqlCompareOperatorType.Equals, param );

			foreach (IColumnMap iIdColumnMap in propertyMap.GetAdditionalIdColumnMaps())
			{
				idColumnMap = iIdColumnMap;
				idColumn = table.GetSqlColumnAlias(idColumnMap);

				paramName = GetParameterName(idPropertyMap, idColumnMap);
				if (!(classMap.GetTypeColumnMap() == null && classMap.GetTypeColumnMap() == idColumnMap.MustGetPrimaryKeyColumnMap()))
				{
					param = AddSqlParameter(delete, parameters, paramName, obj, null, classMap.TypeValue, idColumnMap, true);
				}
				else
				{
					idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());
					param = AddSqlParameter(delete, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap, true);
				}

				search = delete.SqlWhereClause.GetNextSqlSearchCondition();
				search.GetSqlComparePredicate(idColumn, SqlCompareOperatorType.Equals, param );
				
			}
			columnMap = propertyMap.GetColumnMap();
			SqlColumnAlias column = table.GetSqlColumnAlias(columnMap);

			paramName = GetParameterName(propertyMap, "Org_");
			param = AddSqlParameter(delete, parameters, paramName, obj, propertyMap, value, columnMap, true);

			search = delete.SqlWhereClause.GetNextSqlSearchCondition();
			search.GetSqlComparePredicate(column, SqlCompareOperatorType.Equals, param );

			return GenerateSql(delete);
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:59,代码来源:SqlEngineBase.cs

示例14: GetSelectNonPrimaryPropertyStatement

		protected virtual string GetSelectNonPrimaryPropertyStatement(object obj, IPropertyMap propertyMap, ArrayList propertyNames, IList parameters)
		{
			IClassMap classMap;
			IColumnMap columnMap;
			IColumnMap idColumnMap;
			IPropertyMap idPropertyMap;
			IPropertyMap addPropertyMap;
			ITableMap tableMap;
			string paramName = "";
			IContext ctx = m_SqlEngineManager.Context;
			IObjectManager om = ctx.ObjectManager;
			classMap = m_SqlEngineManager.Context.DomainMap.MustGetClassMap(obj.GetType());

			tableMap = propertyMap.MustGetTableMap();

			SqlSelectStatement select = new SqlSelectStatement(tableMap.SourceMap) ; 
			SqlTableAlias table = select.GetSqlTableAlias(tableMap);

			columnMap = propertyMap.GetColumnMap();
			SqlColumnAlias column = table.GetSqlColumnAlias(columnMap);

			select.SqlSelectClause.AddSqlAliasSelectListItem(column);
			propertyNames.Add(propertyMap.Name);

			foreach (IPropertyMap iAddPropertyMap in classMap.GetAllPropertyMaps())
			{
				addPropertyMap = iAddPropertyMap;
				if (addPropertyMap.MustGetTableMap() == tableMap)
				{
					if (!(addPropertyMap == propertyMap))
					{
						if (om.GetPropertyStatus(obj, addPropertyMap.Name) == PropertyStatus.NotLoaded)
						{
							if (!((addPropertyMap.IsCollection || (addPropertyMap.ReferenceType != ReferenceType.None && !(addPropertyMap.IsIdentity)))))
							{
								if (!(addPropertyMap.LazyLoad))
								{
									columnMap = addPropertyMap.GetColumnMap();
									column = table.GetSqlColumnAlias(columnMap);

									select.SqlSelectClause.AddSqlAliasSelectListItem(column);
									propertyNames.Add(addPropertyMap.Name);
								}
							}
						}
					}
				}
			}

			select.SqlFromClause.AddSqlAliasTableSource(table);

			if (!(propertyMap.MustGetTableMap() == classMap.MustGetTableMap()))
			{
				idColumnMap = propertyMap.GetIdColumnMap();
				idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());

				SqlColumnAlias idColumn = table.GetSqlColumnAlias(idColumnMap);

				paramName = GetParameterName(propertyMap, "Id_");
				SqlParameter param = AddSqlParameter(select, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap, true);

				SqlSearchCondition search = select.SqlWhereClause.GetNextSqlSearchCondition();
				search.GetSqlComparePredicate(idColumn, SqlCompareOperatorType.Equals, param);

				foreach (IColumnMap iIdColumnMap in propertyMap.GetAdditionalIdColumnMaps())
				{
					idColumnMap = iIdColumnMap;

					idColumn = table.GetSqlColumnAlias(idColumnMap);

					paramName = GetParameterName(propertyMap, idColumnMap, "Id_");
					if (!(classMap.GetTypeColumnMap() == null && classMap.GetTypeColumnMap() == idColumnMap.MustGetPrimaryKeyColumnMap()))
						param = AddSqlParameter(select, parameters, paramName, obj, null, classMap.TypeValue, idColumnMap, true);
					else
					{
						idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());						
						param = AddSqlParameter(select, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap, true);
					}

					search = select.SqlWhereClause.GetNextSqlSearchCondition();
					search.GetSqlComparePredicate(idColumn, SqlCompareOperatorType.Equals, param);
				}
			}
			else
			{
				foreach (IPropertyMap iPropertyMap in classMap.GetIdentityPropertyMaps())
				{
					propertyMap = iPropertyMap;
					columnMap = propertyMap.GetColumnMap();

					SqlColumnAlias idColumn = table.GetSqlColumnAlias(columnMap);

					paramName = GetParameterName(propertyMap, "Id_");
					SqlParameter param;

					if (om.GetPropertyStatus(obj, propertyMap.Name) == PropertyStatus.Dirty)
						param = AddSqlParameter(select, parameters, paramName, obj, propertyMap, om.GetOriginalPropertyValue(obj, propertyMap.Name), columnMap, true);
					else
						param = AddSqlParameter(select, parameters, paramName, obj, propertyMap, om.GetPropertyValue(obj, propertyMap.Name), columnMap);

//.........这里部分代码省略.........
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:101,代码来源:SqlEngineBase.cs

示例15: ManageReferenceValue

        //if value is a list, values in list come in the same order as columns are returned from propertymap.refClassMap.GetIdentityCols! garantueed order !
        //type column value must have been extracted from list in advance and should be passed to discriminator param
        public virtual object ManageReferenceValue(object obj, IPropertyMap propertyMap, object value, object discriminator)
        {
            IClassMap refClassMap;
            IPropertyMap mapToId;
            if (!(propertyMap.ReferenceType == ReferenceType.None))
            {
                if (value != null)
                {
                    refClassMap = propertyMap.MustGetReferencedClassMap();
                    if (discriminator != null)
                    {
                        try
                        {
                            discriminator = discriminator.ToString() ;
                        }
                        catch { discriminator = ""; }
                        refClassMap = refClassMap.GetSubClassWithTypeValue((string) discriminator);
                        if (refClassMap == null)
                            throw new NPersistException("Could not find class map with type value '" + (string) discriminator + "'");
                    }
                    //TODO: bug if one slave prop in a subclass references another subclass in single table inheritance
                    IColumnMap propertyColumnMap = propertyMap.GetColumnMap();
                    IColumnMap inverseColumnMap = propertyColumnMap.MustGetPrimaryKeyColumnMap();
                    mapToId = refClassMap.MustGetPropertyMapForColumnMap(inverseColumnMap);

                    if (mapToId.IsIdentity)
                        value = this.Context.GetObjectById(value, this.Context.AssemblyManager.MustGetTypeFromClassMap(refClassMap), true);
                    else
                        value = this.Context.GetObjectByKey(mapToId.Name, Convert.ToString(value), obj.GetType().GetProperty(propertyMap.Name).PropertyType);
                }
            }
            return value;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:35,代码来源:PersistenceManager.cs


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