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


C# SqlCommand.SqlString类代码示例

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


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

示例1: AddJoin

		public override void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType,
		                             SqlString on)
		{
			//arbitrary on clause ignored!!
			AddJoin(tableName, alias, fkColumns, pkColumns, joinType);
			AddCondition(on);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:InformixJoinFragment.cs

示例2: BasicCollectionJoinWalker

		public BasicCollectionJoinWalker(
			IQueryableCollection collectionPersister,
			int batchSize,
			SqlString subquery,
			ISessionFactoryImplementor factory,
			IDictionary enabledFilters)
			: base(factory, enabledFilters)
		{
			this.collectionPersister = collectionPersister;
			string alias = GenerateRootAlias(collectionPersister.Role);

			WalkCollectionTree(collectionPersister, alias);

			IList allAssociations = new ArrayList();

			ArrayHelper.AddAll(allAssociations, associations);
			allAssociations.Add(new OuterJoinableAssociation(
			                    	collectionPersister.CollectionType,
			                    	null,
			                    	null,
			                    	alias,
			                    	JoinType.LeftOuterJoin,
			                    	Factory,
			                    	enabledFilters
			                    	));
			InitPersisters(allAssociations, LockMode.None);
			InitStatementString(alias, batchSize, subquery);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:28,代码来源:BasicCollectionJoinWalker.cs

示例3: Generate

		public object Generate(ISessionImplementor session, object obj)
		{
			var sql = new SqlString(session.Factory.Dialect.SelectGUIDString);
			try
			{
				IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes);
				IDataReader reader = null;
				try
				{
					reader = session.Batcher.ExecuteReader(st);
					object result;
					try
					{
						reader.Read();
						result = IdentifierGeneratorFactory.Get(reader, identifierType, session);
					}
					finally
					{
						reader.Close();
					}
					log.Debug("GUID identifier generated: " + result);
					return result;
				}
				finally
				{
					session.Batcher.CloseCommand(st, reader);
				}
			}
			catch (Exception sqle)
			{
				throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, "could not retrieve GUID", sql);
			}
		}
开发者ID:renefc3,项目名称:nhibernate,代码行数:33,代码来源:NativeGuidGenerator.cs

示例4: InitAll

		protected void InitAll(
			SqlString whereString,
			string orderByString,
			LockMode lockMode)
		{
			WalkEntityTree(persister, Alias);
			IList allAssociations = new ArrayList();
			foreach (object obj in associations)
			{
				allAssociations.Add(obj);
			}
			allAssociations.Add(
				new OuterJoinableAssociation(
					persister.EntityType,
					null,
					null,
					alias,
					JoinType.LeftOuterJoin,
					Factory,
					CollectionHelper.EmptyMap
					));

			InitPersisters(allAssociations, lockMode);
			InitStatementString(whereString, orderByString, lockMode);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:25,代码来源:AbstractEntityJoinWalker.cs

示例5: InitStatementString

		private void InitStatementString(IOuterJoinLoadable elementPersister, string alias, int batchSize, SqlString subquery)
		{
			int joins = CountEntityPersisters(associations);
			Suffixes = BasicLoader.GenerateSuffixes(joins + 1);

			int collectionJoins = CountCollectionPersisters(associations) + 1;
			CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins);

			SqlStringBuilder whereString = WhereString(alias, oneToManyPersister.KeyColumnNames, subquery, batchSize);
			string filter = oneToManyPersister.FilterFragment(alias, EnabledFilters);
			whereString.Insert(0, StringHelper.MoveAndToBeginning(filter));

			JoinFragment ojf = MergeOuterJoins(associations);
			SqlSelectBuilder select =
				new SqlSelectBuilder(Factory).SetSelectClause(
					oneToManyPersister.SelectFragment(null, null, alias, Suffixes[joins], CollectionSuffixes[0], true)
					+ SelectString(associations)).SetFromClause(elementPersister.FromTableFragment(alias)
					                                            + elementPersister.FromJoinFragment(alias, true, true)).SetWhereClause(
					whereString.ToSqlString()).SetOuterJoins(ojf.ToFromFragmentString,
					                                         ojf.ToWhereFragmentString
					                                         + elementPersister.WhereJoinFragment(alias, true, true));

			select.SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias)));

			if (Factory.Settings.IsCommentsEnabled)
			{
				select.SetComment("load one-to-many " + oneToManyPersister.Role);
			}

			SqlString = select.ToSqlString();
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:31,代码来源:OneToManyJoinWalker.cs

示例6: GetLimitString_NoOffsetSpecified_UsesFetchFirstOnly

		public void GetLimitString_NoOffsetSpecified_UsesFetchFirstOnly()
		{
			// arrange
			DB2Dialect dialect = new DB2Dialect();
			SqlString sql = new SqlString(
				new object[]
					{
						"select a, b, c ",
						"from d",
						" where X = ",
						Parameter.Placeholder,
						" and Z = ",
						Parameter.Placeholder,
						" order by a, x"
					});

			// act
			SqlString limited = dialect.GetLimitString(sql, null, new SqlString("222"));

			// assert
			Assert.AreEqual(
				"select a, b, c from d where X = ? and Z = ? order by a, x fetch first 222 rows only",
				limited.ToString());
			Assert.AreEqual(2, limited.GetParameterCount());
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:25,代码来源:DB2DialectFixture.cs

示例7: ExtendMessage

 public static string ExtendMessage(string message, SqlString sql, object[] parameterValues, IDictionary namedParameters)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(message).Append(Environment.NewLine).
         Append("[ ").Append(sql).Append(" ]");
     if (parameterValues != null && parameterValues.Length > 0)
     {
         sb.Append(Environment.NewLine).Append("Positional parameters: ");
         int index = 0;
         foreach (object parameterValue in parameterValues)
         {
             object value = parameterValue;
             if (value == null)
                 value = "null";
             sb.Append(" #").Append(index).Append(">").Append(value);
         }
     }
     if (namedParameters != null && namedParameters.Count > 0)
     {
         sb.Append(Environment.NewLine);
         foreach (DictionaryEntry namedParameter in namedParameters)
         {
             object value = namedParameter.Value;
             if (value == null)
                 value = "null";
             sb.Append("  ").Append("Name:").Append(namedParameter.Key)
                 .Append(" - Value:").Append(value);
         }
     }
     sb.Append(Environment.NewLine);
     return sb.ToString();
 }
开发者ID:zibler,项目名称:zibler,代码行数:32,代码来源:ADOExceptionHelper.cs

示例8: Convert

 public static ADOException Convert(ISQLExceptionConverter converter, Exception sqle, string message, SqlString sql,
     object[] parameterValues, IDictionary namedParameters)
 {
     string extendMessage = ExtendMessage(message, sql, parameterValues, namedParameters);
     ADOExceptionReporter.LogExceptions(sqle, extendMessage);
     return new ADOException(extendMessage, sqle, sql);
 }
开发者ID:zibler,项目名称:zibler,代码行数:7,代码来源:ADOExceptionHelper.cs

示例9: GetLimitString

		public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)
		{
			var result = new SqlStringBuilder(querySqlString);

			if (offset != null)
			{
				result.Add(" OFFSET ").Add(offset).Add(" ROWS");
			}

			if (limit != null)
			{
				if (offset == null)
				{
					result.Add(" OFFSET 0 ROWS");

					// According to Oracle Docs: 
					// http://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljoffsetfetch.html
					// the 'limit' param must be 1 or higher, but we have situations with limit=0.
					// This leads to undetermined behaviour of Oracle DBMS. It seems that the query
					// was executed correctly but the execution takes pretty long time.
					//
					// Empirically estimated that adding 'OFFSET 0 ROWS' to these types of queries 
					// ensures much faster execution. Stated above is a kind of hack to fix 
					// described situation.
				}
				result.Add(" FETCH FIRST ").Add(limit).Add(" ROWS ONLY");
			}

			return result.ToSqlString();
		}
开发者ID:barser,项目名称:nhibernate-core,代码行数:30,代码来源:Oracle12cDialect.cs

示例10: Convert

		/// <summary> 
		/// Converts the given SQLException into Exception hierarchy, as well as performing
		/// appropriate logging. 
		/// </summary>
		/// <param name="converter">The converter to use.</param>
		/// <param name="sqlException">The exception to convert.</param>
		/// <param name="message">An optional error message.</param>
		/// <param name="sql">The SQL executed.</param>
		/// <returns> The converted <see cref="ADOException"/>.</returns>
		public static Exception Convert(ISQLExceptionConverter converter, Exception sqlException, string message,
		                                   SqlString sql)
		{
			return Convert(converter,
			               new AdoExceptionContextInfo
			               	{SqlException = sqlException, Message = message, Sql = sql != null ? sql.ToString() : null});
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:16,代码来源:ADOExceptionHelper.cs

示例11: Convert

		public static ADOException Convert(Exception sqle, string message, SqlString sql, object[] parameterValues,
		                                   IDictionary namedParameters)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append(message).Append(Environment.NewLine).
				Append("[ ").Append(sql).Append(" ]")
				.Append(Environment.NewLine);
			if (parameterValues != null && parameterValues.Length > 0)
			{
				sb.Append("Positional parameters: ");
				int index = 0;
				foreach (object parameterValue in parameterValues)
				{
					object value = parameterValue;
					if (value == null)
						value = "null";
					sb.Append("  ").Append(index).Append(" ").Append(value).Append(Environment.NewLine);
				}
			}
			if (namedParameters != null && namedParameters.Count > 0)
			{
				foreach (DictionaryEntry namedParameter in namedParameters)
				{
					object value = namedParameter.Value;
					if (value == null)
						value = "null";
					sb.Append("  ").Append("Name: ").Append(namedParameter.Key)
						.Append(" - Value: ").Append(value).Append(Environment.NewLine);
				}
			}
			ADOExceptionReporter.LogExceptions(sqle, sb.ToString());
			return new ADOException(sb.ToString(), sqle, sql);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:33,代码来源:ADOExceptionHelper.cs

示例12: InitProjection

		protected void InitProjection(SqlString projectionString, SqlString whereString,
			string orderByString, string groupByString, LockMode lockMode)
		{
			WalkEntityTree(persister, Alias);
			Persisters = new ILoadable[0];
			InitStatementString(projectionString, whereString, orderByString, groupByString, lockMode);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:7,代码来源:AbstractEntityJoinWalker.cs

示例13: InitStatementString

		private void InitStatementString(SqlString projection,SqlString condition,
			string orderBy,string groupBy,LockMode lockMode)
		{
			int joins = CountEntityPersisters(associations);
			Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
			JoinFragment ojf = MergeOuterJoins(associations);

			SqlString selectClause = projection
			                         ??
			                         new SqlString(persister.SelectFragment(alias, Suffixes[joins]) + SelectString(associations));
			
			SqlSelectBuilder select = new SqlSelectBuilder(Factory)
				.SetLockMode(lockMode)
				.SetSelectClause(selectClause)
				.SetFromClause(Dialect.AppendLockHint(lockMode, persister.FromTableFragment(alias)) +persister.FromJoinFragment(alias, true, true))
				.SetWhereClause(condition)
				.SetOuterJoins(ojf.ToFromFragmentString,ojf.ToWhereFragmentString + WhereFragment)
				.SetOrderByClause(OrderBy(associations, orderBy))
				.SetGroupByClause(groupBy);

			if (Factory.Settings.IsCommentsEnabled)
				select.SetComment(Comment);

			SqlString = select.ToSqlString();
		}
开发者ID:pallmall,项目名称:WCell,代码行数:25,代码来源:AbstractEntityJoinWalker.cs

示例14: SubselectOneToManyLoader

		public SubselectOneToManyLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys,
		                                QueryParameters queryParameters,
		                                ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters)
			: base(persister, BatchSizeForSubselectFetching, factory, enabledFilters)
		{
			keys = new object[entityKeys.Count];
			int i = 0;
			foreach (EntityKey entityKey in entityKeys)
			{
				keys[i++] = entityKey.Identifier;
			}

			// NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters
			namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters);
			parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList();
			var processedRowSelection = queryParameters.ProcessedRowSelection;
			SqlString finalSubquery = subquery;
			if (queryParameters.ProcessedRowSelection != null && !SubselectClauseExtractor.HasOrderBy(queryParameters.ProcessedSql))
			{
				// when the original query has an "ORDER BY" we can't re-apply the pagination.
				// This is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination.
				finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters);
			}
			InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory);

			types = queryParameters.PositionalParameterTypes;
			values = queryParameters.PositionalParameterValues;
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:28,代码来源:SubselectOneToManyLoader.cs

示例15: SubselectClauseExtractor

		/// <summary>
		/// Initializes a new instance of the <see cref="SubselectClauseExtractor"/> class.
		/// </summary>
		/// <param name="sql">The <see cref="SqlString" /> to extract the subselect clause from.</param>
		public SubselectClauseExtractor(SqlString sql)
		{
			builder = new SqlStringBuilder(sql.Count);
			this.sql = sql;
			lastOrderByIndex = -1;
			lastOrderByPartIndex = -1;
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:11,代码来源:SubselectClauseExtractor.cs


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