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

📄 noargsqlfunction.cs

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

namespace NHibernate.Dialect.Function
{
	/// <summary>
	/// Summary description for NoArgSQLFunction.
	/// </summary>
	public class NoArgSQLFunction : ISQLFunction
	{
		protected readonly IType returnType = null;
		protected readonly string name;
		private readonly bool hasParenthesesIfNoArguments;

		public NoArgSQLFunction(string name, IType returnType) : this(name, returnType, true)
		{
		}

		public NoArgSQLFunction(string name, IType returnType, bool hasParenthesesIfNoArguments)
		{
			this.name = name;
			this.returnType = returnType;
			this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments;
		}

		protected IType FunctionReturnType
		{
			get { return returnType; }
		}

		protected string Name
		{
			get { return name; }
		}

		#region ISQLFunction Members

		public IType ReturnType(IType columnType, IMapping mapping)
		{
			return returnType;
		}

		public bool HasArguments
		{
			get { return false; }
		}

		public bool HasParenthesesIfNoArguments
		{
			get { return hasParenthesesIfNoArguments; }
		}

		public virtual SqlString Render(IList args, ISessionFactoryImplementor factory)
		{
			if (args.Count > 0)
			{
				throw new QueryException("function takes no arguments: " + name);
			}
			SqlStringBuilder buf = new SqlStringBuilder(2);
			buf.Add(name);
			if (hasParenthesesIfNoArguments)
			{
				buf.Add("()");
			}
			return buf.ToSqlString();
		}

		#endregion
	}
}

⌨️ 快捷键说明

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