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


C# SqlString.ToString方法代码示例

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


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

示例1: Convert

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

示例2: Replace

		public void Replace()
		{
			SqlString sql =
				new SqlString(
					new object[] {"select ", "from table ", "where a = ", Parameter.Placeholder, " and c = ", Parameter.Placeholder});
			SqlString replacedSql = sql.Replace("table", "replacedTable");
			Assert.AreEqual(sql.ToString().Replace("table", "replacedTable"), replacedSql.ToString());

			replacedSql = sql.Replace("not found", "not in here");
			Assert.AreEqual(sql.ToString().Replace("not found", "not in here"), replacedSql.ToString(), "replace no found string");

			replacedSql = sql.Replace("le", "LE");
			Assert.AreEqual(sql.ToString().Replace("le", "LE"), replacedSql.ToString(), "multi-match replace");
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:14,代码来源:SqlStringFixture.cs

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

示例4: CompareSqlStrings

		protected void CompareSqlStrings(SqlString actualSqlString, string expectedString, int expectedNumOfParameters) 
		{
			Parameter[] actualParameters = new Parameter[expectedNumOfParameters];
			int numOfParameters = 0;

			GetParameters(actualSqlString, ref actualParameters, ref numOfParameters);
			Assert.AreEqual(expectedString, actualSqlString.ToString(), "SqlString.ToString()");
			Assert.AreEqual(expectedNumOfParameters, numOfParameters, "Num of Parameters");

		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:10,代码来源:BaseExpressionFixture.cs

示例5: Generate

		public IDbCommand Generate(CommandType type, SqlString sqlString, SqlType[] parameterTypes)
		{
			IDbCommand cmd = factory.ConnectionProvider.Driver.GenerateCommand(type, sqlString, parameterTypes);
			LogOpenPreparedCommand();
			if (log.IsDebugEnabled)
			{
				log.Debug("Building an IDbCommand object for the SqlString: " + sqlString.ToString());
			}
			commandsToClose.Add(cmd);
			return cmd;
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:11,代码来源:BatcherImpl.cs

示例6: Generate

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sqlString"></param>
		/// <returns></returns>
		public IDbCommand Generate( SqlString sqlString )
		{
			// need to build the IDbCommand from the sqlString bec
			IDbCommand cmd = factory.ConnectionProvider.Driver.GenerateCommand( factory.Dialect, sqlString );
			LogOpenPreparedCommand();
			if( log.IsDebugEnabled )
			{
				log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() );
			}
			commandsToClose.Add( cmd );
			return cmd;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:17,代码来源:BatcherImpl.cs

示例7: AddLeftOuterJoinCondition

		/// <summary>
		/// This method is a bit of a hack, and assumes
		/// that the column on the "right" side of the
		/// join appears on the "left" side of the
		/// operator, which is extremely weird if this
		/// was a normal join condition, but is natural
		/// for a filter.
		/// </summary>
		private void AddLeftOuterJoinCondition(SqlString on)
		{
			StringBuilder buf = new StringBuilder(on.ToString());
			for (int i = 0; i < buf.Length; i++)
			{
				char character = buf[i];
				bool isInsertPoint = Operators.Contains(character) ||
				                     (character == ' ' && buf.Length > i + 3 && "is ".Equals(buf.ToString(i + 1, 3)));
				if (isInsertPoint)
				{
					buf.Insert(i, "(+)");
					i += 3;
				}
			}
			AddCondition(SqlString.Parse(buf.ToString()));
		}
开发者ID:nikson,项目名称:nhibernate-core,代码行数:24,代码来源:OracleJoinFragment.cs

示例8: DetermineNumberOfPreceedingParametersForEachQuery

		private void DetermineNumberOfPreceedingParametersForEachQuery(SqlString text)
		{
			int currentParameterIndex = 0;
			int currentQueryParameterCount = 0;
			int currentQueryIndex = 0;
			hasReturnParameter = false;
			foundReturnParameter = false;

			CallableParser.Detail callableDetail = CallableParser.Parse(text.ToString());

			if (callableDetail.IsCallable && callableDetail.HasReturn)
				hasReturnParameter = true;

			foreach (object part in text.Parts)
			{
				if (part.ToString().Equals(multipleQueriesSeparator))
				{
					queryIndexToNumberOfPreceedingParameters[currentQueryIndex] = currentParameterIndex - currentQueryParameterCount;
					currentQueryParameterCount = 0;
					currentQueryIndex++;
					continue;
				}

				Parameter parameter = part as Parameter;

				if (parameter != null)
				{
					if (hasReturnParameter && !foundReturnParameter)
					{
						foundReturnParameter = true;
					}
					else
					{
						parameterIndexToQueryIndex[currentParameterIndex] = currentQueryIndex;
					}
					currentQueryParameterCount++;
					currentParameterIndex++;
				}
			}
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:40,代码来源:SqlStringFormatter.cs

示例9: ProcessFilters

		public void ProcessFilters(SqlString sql, ISessionImplementor session)
		{
			filteredParameterValues = new List<object>();
			filteredParameterTypes = new List<IType>();
			filteredParameterLocations = new List<int>();

			if (session.EnabledFilters.Count == 0 || sql.ToString().IndexOf(ParserHelper.HqlVariablePrefix) < 0)
			{
				processedSQL = sql.Copy();
				return;
			}

			Dialect.Dialect dialect = session.Factory.Dialect;
			string symbols = ParserHelper.HqlSeparators + dialect.OpenQuote + dialect.CloseQuote;

			var result = new SqlStringBuilder();

			int originalParameterIndex = 0; // keep track of the positional parameter
			int newParameterIndex = 0;
			_adjustedParameterLocations = new Dictionary<int, int>();

			foreach (var part in sql.Parts)
			{
				if (part is Parameter)
				{
					result.AddParameter();

					// (?) can be a position parameter or a named parameter (already substituted by (?),
					// but only the positional parameters are available at this point. Adding them in the
					// order of appearance is best that can be done at this point of time, but if they
					// are mixed with named parameters, the order is still wrong, because values and
					// types for the named parameters are added later to the end of the list.
					// see test fixture NH-1098

					_adjustedParameterLocations[originalParameterIndex] = newParameterIndex;
					originalParameterIndex++;
					newParameterIndex++;
					continue;
				}

				var tokenizer = new StringTokenizer((string) part, symbols, true);

				foreach (var token in tokenizer)
				{
					if (token.StartsWith(ParserHelper.HqlVariablePrefix))
					{
						string filterParameterName = token.Substring(1);
						object value = session.GetFilterParameterValue(filterParameterName);
						IType type = session.GetFilterParameterType(filterParameterName);

						// If the value is not a value of the type but a collection of values...
						if (value != null && !type.ReturnedClass.IsAssignableFrom(value.GetType()) && // Added to fix NH-882
						    typeof (ICollection).IsAssignableFrom(value.GetType()))
						{
							var coll = (ICollection) value;
							int i = 0;
							foreach (var elementValue in coll)
							{
								i++;
								int span = type.GetColumnSpan(session.Factory);
								if (span > 0)
								{
									result.AddParameter();
									filteredParameterTypes.Add(type);
									filteredParameterValues.Add(elementValue);
									filteredParameterLocations.Add(newParameterIndex);
									newParameterIndex++;
									if (i < coll.Count)
									{
										result.Add(", ");
									}
								}
							}
						}
						else
						{
							int span = type.GetColumnSpan(session.Factory);
							if (span > 0)
							{
								result.AddParameter();
								filteredParameterTypes.Add(type);
								filteredParameterValues.Add(value);
								filteredParameterLocations.Add(newParameterIndex);
								newParameterIndex++;
							}
						}
					}
					else
					{
						result.Add(token);
					}
				}
			}

			processedSQL = result.ToSqlString();
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:96,代码来源:QueryParameters.cs

示例10: TrimAllParam

		public void TrimAllParam()
		{
			Parameter p1 = Parameter.Placeholder;
			Parameter p2 = Parameter.Placeholder;

			SqlString sql = new SqlString(new object[] { p1, p2 });
			sql = sql.Trim();

			Assert.AreEqual("??", sql.ToString());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:10,代码来源:SqlStringFixture.cs

示例11: TrimBeginStringEndParam

		public void TrimBeginStringEndParam()
		{
			Parameter p1 = Parameter.Placeholder;

			SqlString sql = new SqlString(new object[] { "   extra space   ", p1 });
			sql = sql.Trim();

			Assert.AreEqual("extra space   ?", sql.ToString());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:9,代码来源:SqlStringFixture.cs

示例12: TrimBeginParamEndString

		public void TrimBeginParamEndString()
		{
			Parameter p1 = Parameter.Placeholder;

			SqlString sql = new SqlString(new object[] { p1, "   extra space   " });
			sql = sql.Trim();

			Assert.AreEqual("?   extra space", sql.ToString());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:9,代码来源:SqlStringFixture.cs

示例13: TrimAllString

		public void TrimAllString()
		{
			SqlString sql = new SqlString(new string[] { "   extra space", " in the middle", " at the end     " });
			sql = sql.Trim();

			Assert.AreEqual("extra space in the middle at the end", sql.ToString());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:7,代码来源:SqlStringFixture.cs

示例14: OnPrepareStatement

 public override SqlString OnPrepareStatement(SqlString sql)
 {
     Trace.WriteLine(sql.ToString());
     return base.OnPrepareStatement(sql);
 }
开发者ID:kruglik-alexey,项目名称:jeegoordah,代码行数:5,代码来源:LoggingInterceptor.cs

示例15: CompareSqlStrings

		/// <summary>
		/// This compares the text output of the SqlString to what was expected.  It does
		/// not take into account the parameters.
		/// </summary>
		protected void CompareSqlStrings(SqlString actualSqlString, string expectedString)
		{
			Assert.AreEqual(expectedString, actualSqlString.ToString(), "SqlString.ToString()");
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:8,代码来源:BaseExpressionFixture.cs


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