當前位置: 首頁>>代碼示例>>C#>>正文


C# SqlCommand.SelectFragment類代碼示例

本文整理匯總了C#中NHibernate.SqlCommand.SelectFragment的典型用法代碼示例。如果您正苦於以下問題:C# SelectFragment類的具體用法?C# SelectFragment怎麽用?C# SelectFragment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SelectFragment類屬於NHibernate.SqlCommand命名空間,在下文中一共展示了SelectFragment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateIdInsertSelect

		protected SqlString GenerateIdInsertSelect(IQueryable persister, string tableAlias, IASTNode whereClause)
		{
			var select = new SqlSelectBuilder(Factory);
			SelectFragment selectFragment = new SelectFragment(Factory.Dialect)
				.AddColumns(tableAlias, persister.IdentifierColumnNames, persister.IdentifierColumnNames);
			select.SetSelectClause(selectFragment.ToFragmentString().Substring(2));

			string rootTableName = persister.TableName;
			SqlString fromJoinFragment = persister.FromJoinFragment(tableAlias, true, false);
			SqlString whereJoinFragment = persister.WhereJoinFragment(tableAlias, true, false);

			select.SetFromClause(rootTableName + ' ' + tableAlias + fromJoinFragment);

			if (whereJoinFragment == null)
			{
				whereJoinFragment = SqlString.Empty;
			}
			else
			{
				whereJoinFragment = whereJoinFragment.Trim();
				if (whereJoinFragment.StartsWithCaseInsensitive("and "))
				{
					whereJoinFragment = whereJoinFragment.Substring(4);
				}
			}

			SqlString userWhereClause = SqlString.Empty;
			if (whereClause.ChildCount != 0)
			{
				// If a where clause was specified in the update/delete query, use it to limit the
				// returned ids here...
				try
				{
					var nodes = new CommonTreeNodeStream(whereClause);
					var gen = new SqlGenerator(Factory, nodes);
					gen.whereClause();
					userWhereClause = gen.GetSQL().Substring(7);
				}
				catch (RecognitionException e)
				{
					throw new HibernateException("Unable to generate id select for DML operation", e);
				}
				if (whereJoinFragment.Length > 0)
				{
					whereJoinFragment.Append(" and ");
				}
			}

			select.SetWhereClause(whereJoinFragment + userWhereClause);

			var insert = new InsertSelect();
			if (Factory.Settings.IsCommentsEnabled)
			{
				insert.SetComment("insert-select for " + persister.EntityName + " ids");
			}
			insert.SetTableName(persister.TemporaryIdTableName);
			insert.SetSelect(select);
			return insert.ToSqlString();
		}
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:59,代碼來源:AbstractStatementExecutor.cs

示例2: AddDiscriminatorToSelect

		protected override void AddDiscriminatorToSelect(SelectFragment select, string name, string suffix)
		{
			if (IsDiscriminatorFormula)
				select.AddFormula(name, DiscriminatorFormulaTemplate, DiscriminatorAlias);
			else
				select.AddColumn(name, DiscriminatorColumnName, DiscriminatorAlias);
		}
開發者ID:juanplopes,項目名稱:nhibernate,代碼行數:7,代碼來源:SingleTableEntityPersister.cs

示例3: AppendIdentifierColumns

		protected virtual void AppendIdentifierColumns(SelectFragment frag, string alias)
		{
			if (hasIdentifier)
			{
				frag.AddColumn(alias, identifierColumnName, identifierColumnAlias);
			}
		}
開發者ID:khaliyo,項目名稱:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代碼行數:7,代碼來源:AbstractCollectionPersister.cs

示例4: GenerateSelectFragment

		protected override SelectFragment GenerateSelectFragment(string alias, string columnSuffix)
		{
			/*
			 NH-1747 FIX
			 Note: the fix for NH-1747 may cause some problem when the same ColumnName is used to represent two different properties in the same hierarchy
			 In all our test it happened only for NHibernate.Test.Legacy.MultiTableTest.MultiTableCollections
			 The mapping Multi.hbm.xml had a column named "parent" to represent the Key of a set for the relation Lower->Top and SubMulti->SubMulti everything in the same hierarchy
			 NH TODO: Have to add an early check of same ColumnName used to represent two relations.
			*/
			var ojl = (IOuterJoinLoadable)ElementPersister;
			var selectFragment = new SelectFragment(Dialect).SetSuffix(columnSuffix);
			var columnNames = KeyColumnNames;
			var columnAliases = KeyColumnAliases;
			for (int i = 0; i < columnNames.Length; i++)
			{
				var column = columnNames[i];
				var tableAlias = ojl.GenerateTableAliasForColumn(alias, column);
				selectFragment.AddColumn(tableAlias, column, columnAliases[i]);
			}
			return selectFragment;
		}
開發者ID:mrhihi,項目名稱:nhibernate-core,代碼行數:21,代碼來源:OneToManyPersister.cs

示例5: ConcretePropertySelectFragment

		// TODO NH: should remove duplication between this and the other overload,
		// probably using H3 approach (adding indirection through IInclusionChecker interface).
		protected string ConcretePropertySelectFragment(string alias, ValueInclusion[] inclusions)
		{
			int propertyCount = entityMetamodel.PropertySpan;
			int[] propertyTableNumbers = PropertyTableNumbersInSelect;
			SelectFragment frag = new SelectFragment(Factory.Dialect);
			for (int i = 0; i < propertyCount; i++)
			{
				if (inclusions[i] != ValueInclusion.None)
				{
					//ie. updateable, not a formula
					frag.AddColumns(
						GenerateTableAlias(alias, propertyTableNumbers[i]),
						propertyColumnNames[i],
						propertyColumnAliases[i]
						);
					frag.AddFormulas(
						GenerateTableAlias(alias, propertyTableNumbers[i]),
						propertyColumnFormulaTemplates[i],
						propertyColumnAliases[i]
						);
				}
			}
			return frag.ToSqlStringFragment();
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:26,代碼來源:AbstractEntityPersister.cs

示例6: AppendIndexColumns

		protected virtual void AppendIndexColumns(SelectFragment frag, string alias)
		{
			if (hasIndex)
			{
				for (int i = 0; i < indexColumnIsSettable.Length; i++)
				{
					if (indexColumnIsSettable[i])
					{
						frag.AddColumn(alias, indexColumnNames[i], indexColumnAliases[i]);
					}
					else
					{
						frag.AddFormula(alias, indexFormulaTemplates[i], indexColumnAliases[i]);
					}
				}
			}
		}
開發者ID:khaliyo,項目名稱:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代碼行數:17,代碼來源:AbstractCollectionPersister.cs

示例7: AddDiscriminatorToSelect

		protected override void AddDiscriminatorToSelect(SelectFragment select, string name, string suffix)
		{
			select.AddColumn(name, DiscriminatorColumnName, DiscriminatorAlias);
		}
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:4,代碼來源:UnionSubclassEntityPersister.cs

示例8: ConcretePropertySelectFragment

		protected string ConcretePropertySelectFragment(string alias, IInclusionChecker inclusionChecker)
		{
			int propertyCount = PropertyNames.Length;
			int[] propertyTableNumbers = PropertyTableNumbersInSelect;
			SelectFragment frag = new SelectFragment(Factory.Dialect);
			for (int i = 0; i < propertyCount; i++)
			{
				if (inclusionChecker.IncludeProperty(i))
				{
					frag.AddColumns(GenerateTableAlias(alias, propertyTableNumbers[i]), propertyColumnNames[i], propertyColumnAliases[i]);
					frag.AddFormulas(GenerateTableAlias(alias, propertyTableNumbers[i]), propertyColumnFormulaTemplates[i], propertyColumnAliases[i]);
				}
			}
			return frag.ToFragmentString();
		}
開發者ID:rbirkby,項目名稱:nhibernate-core,代碼行數:15,代碼來源:AbstractEntityPersister.cs

示例9: GenerateSelectFragment

		protected virtual SelectFragment GenerateSelectFragment(string alias, string columnSuffix)
		{
			SelectFragment frag = new SelectFragment(dialect)
				.SetSuffix(columnSuffix)
				.AddColumns(alias, keyColumnNames, keyColumnAliases);

			return frag;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:8,代碼來源:AbstractCollectionPersister.cs

示例10: AppendIndexColumns

		protected virtual void AppendIndexColumns(SelectFragment frag, string alias)
		{
			if (hasIndex)
			{
				frag.AddColumns(alias, indexColumnNames, indexColumnAliases);
			}
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:7,代碼來源:AbstractCollectionPersister.cs

示例11: PropertySelectFragment

		public override SqlString PropertySelectFragment( string alias, string suffix )
		{
			SelectFragment frag = new SelectFragment( factory.Dialect )
				.SetSuffix( suffix )
				.SetUsedAliases( IdentifierAliases );

			for( int i = 0; i < subclassColumnClosure.Length; i++ )
			{
				string subalias = Alias( alias, subclassColumnTableNumberClosure[ i ] );
				frag.AddColumn( subalias, subclassColumnClosure[ i ], subclassColumnClosureAliases[ i ]	);
			}

			for( int i = 0; i < subclassFormulaTemplateClosure.Length; i++ )
			{
				string subalias = Alias( alias, subclassFormulaTableNumberClosure[ i ] );
				frag.AddFormula( subalias, subclassFormulaTemplateClosure[ i ], subclassFormulaAliasClosure[ i ]	);
			}

			if( HasSubclasses )
			{
				SqlStringBuilder builder = new SqlStringBuilder( 3 );

				builder.Add( StringHelper.CommaSpace );
				builder.Add(
					DiscriminatorFragment( alias )
						.SetReturnColumnName( DiscriminatorAlias, suffix )
						.ToSqlStringFragment()
					);

				builder.Add( frag.ToSqlStringFragment() );

				return builder.ToSqlString();
			}
			else
			{
				return frag.ToSqlStringFragment();
			}
		}
開發者ID:rcarrillopadron,項目名稱:nhibernate-1.0.2.0,代碼行數:38,代碼來源:NormalizedEntityPersister.cs

示例12: ConcretePropertySelectFragment

		private SqlString ConcretePropertySelectFragment( string alias, bool[] includeProperty )
		{
			int propertyCount = propertyColumnNames.Length;
			SelectFragment frag = new SelectFragment( Dialect );

			for( int i = 0; i < propertyCount; i++ )
			{
				if( includeProperty[ i ] )
				{
					frag.AddColumns(
						Alias( alias, propertyTables[ i ] ),
						propertyColumnNames[ i ],
						propertyColumnNameAliases[ i ] );
				}
			}

			return frag.ToSqlStringFragment( );
		}
開發者ID:rcarrillopadron,項目名稱:nhibernate-1.0.2.0,代碼行數:18,代碼來源:NormalizedEntityPersister.cs

示例13: SelectFragment

		public SqlString SelectFragment( string alias )
		{
			SelectFragment frag = new SelectFragment( dialect )
				.SetSuffix( String.Empty ) //always ignore suffix for collection columns
				.AddColumns( alias, keyColumnNames, keyColumnAliases )
				.AddColumns( alias, elementColumnNames, elementColumnAliases );
			if( hasIndex )
			{
				frag.AddColumns( alias, indexColumnNames, indexColumnAliases );
			}
			if( hasIdentifier )
			{
				frag.AddColumn( alias, identifierColumnName, identifierColumnAlias );
			}
			return frag.ToSqlStringFragment( false );
		}
開發者ID:rcarrillopadron,項目名稱:nhibernate-1.0.2.0,代碼行數:16,代碼來源:AbstractCollectionPersister.cs

示例14: AddDiscriminatorToSelect

		protected virtual void AddDiscriminatorToSelect(SelectFragment select, string name, string suffix) { }
開發者ID:rbirkby,項目名稱:nhibernate-core,代碼行數:1,代碼來源:AbstractEntityPersister.cs

示例15: AddDiscriminatorToSelect

		protected override void AddDiscriminatorToSelect(SelectFragment select, string name, string suffix)
		{
			if (HasSubclasses)
			{
				select.SetExtraSelectList(DiscriminatorFragment(name), DiscriminatorAlias);
			}
		}
開發者ID:NikGovorov,項目名稱:nhibernate-core,代碼行數:7,代碼來源:JoinedSubclassEntityPersister.cs


注:本文中的NHibernate.SqlCommand.SelectFragment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。