⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 varargssqlfunction.cs

📁 NHibernate NET开发者所需的
💻 CS
字号:
using System;
using System.Collections;
using System.Text;
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.Type;

namespace NHibernate.Dialect.Function
{
	/// <summary>
	/// Support for slightly more general templating than StandardSQLFunction,
	/// with an unlimited number of arguments.
	/// </summary>
	public class VarArgsSQLFunction : ISQLFunction
	{
		private readonly string begin;
		private readonly string sep;
		private readonly string end;
		private readonly IType returnType = null;

		public VarArgsSQLFunction(string begin, string sep, string end)
		{
			this.begin = begin;
			this.sep = sep;
			this.end = end;
		}

		public VarArgsSQLFunction(IType type, string begin, string sep, string end)
			: this(begin, sep, end)
		{
			this.returnType = type;
		}

		#region ISQLFunction Members

		public virtual IType ReturnType(IType columnType, IMapping mapping)
		{
			return (returnType == null) ? columnType : returnType;
		}

		public bool HasArguments
		{
			get { return true; }
		}

		public bool HasParenthesesIfNoArguments
		{
			get { return true; }
		}

		public SqlString Render(IList args, ISessionFactoryImplementor factory)
		{
			SqlStringBuilder buf = new SqlStringBuilder().Add(begin);
			for (int i = 0; i < args.Count; i++)
			{
				buf.AddObject(args[i]);
				if (i < args.Count - 1) buf.Add(sep);
			}
			return buf.Add(end).ToSqlString();
		}

		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -