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


C# IPropertyMap.MustGetTableMap方法代码示例

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


在下文中一共展示了IPropertyMap.MustGetTableMap方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetListPropertySubselectAndAlias

        public virtual void GetListPropertySubselectAndAlias(IPropertyMap propertyMap, object hash, Hashtable columns, ArrayList order, string propPath, string suggestion)
        {
            if (hash == null) { hash = propertyMap; }
            ITableMap listTableMap = propertyMap.MustGetTableMap();
            ITableMap parentTableMap = propertyMap.ClassMap.MustGetTableMap();
            SqlTableAlias parentTable = sqlEmitter.GetTableAlias(parentTableMap, hash);

            SqlSelectStatement subSelect = new SqlSelectStatement(parentTableMap.SourceMap);

            //Hmmm....can an alias be redefined in a subselect?
            //SqlTableAlias listTable = subSelect.GetSqlTableAlias(listTableMap, "cnt" + subSelect.GetNextTableAliasIndex());
            SqlTableAlias listTable = subSelect.GetSqlTableAlias(listTableMap, "cnt" + sqlEmitter.Select.GetNextTableAliasIndex());

            SqlCountFunction count = new SqlCountFunction();

            subSelect.SqlSelectClause.AddSqlAliasSelectListItem(count);

            subSelect.SqlFromClause.AddSqlAliasTableSource(listTable);

            foreach (IColumnMap fkIdColumnMap in propertyMap.GetAllIdColumnMaps())
            {
                IColumnMap idColumnMap = fkIdColumnMap.MustGetPrimaryKeyColumnMap();

                SqlColumnAlias fkIdColumn = listTable.GetSqlColumnAlias(fkIdColumnMap);
                SqlColumnAlias idColumn = parentTable.GetSqlColumnAlias(idColumnMap);
                SqlSearchCondition search = subSelect.SqlWhereClause.GetNextSqlSearchCondition();

                search.GetSqlComparePredicate(fkIdColumn, SqlCompareOperatorType.Equals, idColumn);
            }

            if (suggestion == "")
                suggestion = propPath;

            SqlAliasSelectListItem countAlias = this.sqlEmitter.Select.SqlSelectClause.AddSqlAliasSelectListItem(subSelect, suggestion);
            this.sqlEmitter.PropertyColumnMap[propPath] = countAlias.SqlExpressionAlias.Alias;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:36,代码来源:PropertyPathTraverser.cs

示例3: GetPropertyColumnNamesAndAliases

        public virtual void GetPropertyColumnNamesAndAliases(IPropertyMap propertyMap, object hash, Hashtable columns, ArrayList order, string path, string propPath, string suggestion)
        {
            if (hash == null) { hash = propertyMap; }
            SqlTableAlias tbl = sqlEmitter.GetTableAlias(propertyMap.MustGetTableMap(), hash)  ;
            IList columnAliases = new ArrayList();

            if (propertyMap.IsIdentity)
            {
                IClassMap classMap = propertyMap.ClassMap;
                IColumnMap typeColumnMap = classMap.GetTypeColumnMap();
                if (typeColumnMap != null)
                {
                    string pathParent = GetPathParent(path);
                    string suggestedPath = pathParent.Length == 0 ? "NPersistTypeColumn" : pathParent + ".NPersistTypeColumn";
                    SqlColumnAlias column = GetPropertyColumnAlias(tbl, suggestedPath , typeColumnMap, suggestedPath);
                    columnAliases.Add(column);
                }
            }

            if (suggestion == "")
                suggestion = propPath;
              //      bool hasTypeColumn = false;

            IPropertyMap inverse = propertyMap.GetInversePropertyMap();

            //Type column first
            if (inverse != null)
            {
                IColumnMap inverseTypeColumnMap = inverse.ClassMap.GetTypeColumnMap();
                foreach (IColumnMap columnMap in propertyMap.GetAllColumnMaps())
                {
                    if (inverseTypeColumnMap != null && inverseTypeColumnMap == columnMap.GetPrimaryKeyColumnMap())
                    {
                        string suggestionString;
                        suggestionString = propPath.Length == 0 ? "NPersistTypeColum" : propPath + ".NPersistTypeColumn";

                        SqlColumnAlias column = GetPropertyColumnAlias(tbl, path, columnMap, suggestionString);
                        columnAliases.Add(column);
                    }
                }
            }

            foreach (IColumnMap columnMap in propertyMap.GetAllColumnMaps())
            {
                if (inverse != null)
                {
                    IColumnMap inverseTypeColumnMap = inverse.ClassMap.GetTypeColumnMap();
                    if ( inverseTypeColumnMap != null && inverseTypeColumnMap == columnMap.GetPrimaryKeyColumnMap())
                    {
                        continue;
                    }
                }

                string suggestionString;

                suggestionString = suggestion;

                SqlColumnAlias column = GetPropertyColumnAlias(tbl, path, columnMap, suggestionString);
                columnAliases.Add(column);
            }

            foreach (SqlColumnAlias column in columnAliases)
            {

                if (!(columns.ContainsKey(column)))
                {
                    columns[column] = column;
                    order.Add(column);

                    //Note: Important stuff, right here in nowhere-ville!!
                    if (this.sqlEmitter.PropertyColumnMap.ContainsKey(propPath))
                    {
                        ArrayList arrAliases;
                        if (this.sqlEmitter.PropertyColumnMap[propPath] is string)
                        {
                            arrAliases = new ArrayList() ;
                            arrAliases.Add(this.sqlEmitter.PropertyColumnMap[propPath]);
                            this.sqlEmitter.PropertyColumnMap[propPath] = arrAliases;
                        }
                        else
                        {
                            arrAliases = (ArrayList) this.sqlEmitter.PropertyColumnMap[propPath];
                        }
                        arrAliases.Add(column.Alias);
                    }
                    else
                    {
                        this.sqlEmitter.PropertyColumnMap[propPath] = column.Alias;
                    }
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:92,代码来源:PropertyPathTraverser.cs

示例4: GetRemoveCollectionPropertyStatement

		protected virtual string GetRemoveCollectionPropertyStatement(object obj, IPropertyMap propertyMap, IList parameters)
		{
			IClassMap classMap;
			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();
			SqlColumnAlias idColumn = table.GetSqlColumnAlias(idColumnMap);
			idPropertyMap = classMap.MustGetPropertyMapForColumnMap(idColumnMap.MustGetPrimaryKeyColumnMap());
			
			paramName = GetParameterName(idPropertyMap, "Id_");
			SqlParameter param =  AddSqlParameter(delete, parameters, paramName, obj, idPropertyMap, om.GetPropertyValue(obj, idPropertyMap.Name), idColumnMap);

			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(propertyMap, idColumnMap, "Id_");
				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);
				}
				search = delete.SqlWhereClause.GetNextSqlSearchCondition();
				search.GetSqlComparePredicate(idColumn, SqlCompareOperatorType.Equals,  param);
								
			}
			return GenerateSql(delete);
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:47,代码来源:SqlEngineBase.cs

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: GetSelectManyOnePropertyStatement

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

            IClassMap rootClassMap = classMap;
            rootTableMap = classMap.MustGetTableMap();
            tableMap = propertyMap.MustGetTableMap();

            if (tableMap != rootTableMap)
            {
                bool done = false;
                while (done == false && rootClassMap.InheritanceType != InheritanceType.ConcreteTableInheritance)
                {
                    done = true;
                    IClassMap super = rootClassMap.GetInheritedClassMap();
                    if (super != null)
                    {
                        if (super.MustGetTableMap() == rootTableMap)
                        {
                            rootClassMap = super ;
                            done = false;
                        }
                    }
                }
                if (rootClassMap == null)
                {
                    rootClassMap = classMap;
                }
            }

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

            idColumnMap = propertyMap.GetIdColumnMap();
            SqlColumnAlias idColumn = table.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 rootTable = table;
            if (tableMap != rootTableMap)
            {
                rootTable = select.GetSqlTableAlias(rootTableMap, "NPersistRootTable");
            }

            SqlTableAlias myTable;
            SqlColumnAlias myColumn;

            IObjectManager om;
            orderByMap = propertyMap.GetOrderByPropertyMap();

            //foreach (IPropertyMap iRefPropertyMap in rootClassMap.GetPrimaryPropertyMaps())
            foreach (IPropertyMap iRefPropertyMap in rootClassMap.GetAllPropertyMaps())
            {
                refPropertyMap = iRefPropertyMap;
                if (refPropertyMap.IsCollection)
                {
                    if (this.Context.PersistenceManager.GetListCountLoadBehavior(LoadBehavior.Default, refPropertyMap) == LoadBehavior.Eager)
                    {
                        if (refPropertyMap.ReferenceType != ReferenceType.None)
                        {
                            ITableMap listTableMap = refPropertyMap.GetTableMap();

                            ISourceMap listSourceMap = listTableMap.SourceMap;

                            SqlSelectStatement subSelect = new SqlSelectStatement(listSourceMap);
                            SqlTableAlias listTable = subSelect.GetSqlTableAlias(listTableMap, "t" + select.GetNextTableAliasIndex());

                            SqlCountFunction count = new SqlCountFunction();

                            subSelect.SqlSelectClause.AddSqlAliasSelectListItem(count);

                            subSelect.SqlFromClause.AddSqlAliasTableSource(listTable);

                            foreach (IColumnMap fkIdColumnMap in refPropertyMap.GetAllIdColumnMaps())
                            {
                                IColumnMap pkIdColumnMap = fkIdColumnMap.MustGetPrimaryKeyColumnMap();

                                SqlColumnAlias fkIdColumn = listTable.GetSqlColumnAlias(fkIdColumnMap);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:101,代码来源:SqlEngineBase.cs

示例10: SetupJoin

		public void SetupJoin(IPropertyMap propertyMap, IPropertyMap parentMap, string propertyPath, JoinType joinType)
		{
			TableJoin tableJoin = GetTableJoinForPropertyPath(propertyPath);
			if (tableJoin == null)
			{
				tableJoin = new TableJoin();
				tableJoin.PropertyMap = propertyMap;
				tableJoin.JoinType = joinType;
				if (parentMap == null)
				{
					tableJoin.JoinTree = this;
					this.propertyPathTraverser.SqlEmitter.GetTableAlias(propertyMap.MustGetTableMap(), propertyMap);
				}
				else
				{
					//make sure the table has an alias
					tableJoin.Parent = GetTableJoinForPropertyPath(propertyPath.Substring(0, propertyPath.Length - propertyMap.Name.Length - 1));
					this.propertyPathTraverser.SqlEmitter.GetTableAlias(propertyMap.MustGetTableMap(), tableJoin.Parent);
				}
			}
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:21,代码来源:JoinTree.cs


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