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

📄 conditionclause.cs

📁 基于LINQ和.NET 3.5 的数据库源码
💻 CS
字号:
using System;
using System.Collections;
using System.Text;
using Lephone.Data.Dialect;
using Lephone.Data.SqlEntry;

namespace Lephone.Data.Builder.Clause
{
	[Serializable]
	public abstract class ConditionClause : WhereCondition
	{
		private readonly string Condition;
		private readonly ArrayList List = new ArrayList();

		public ConditionClause(string Condition)
		{
			this.Condition = Condition;
		}

		public ConditionClause(string Condition, params WhereCondition[] ics) : this(Condition)
		{
			foreach ( WhereCondition ic in ics )
			{
				if ( ic != null )
				{
					Add( ic );
				}
			}
		}

        public override bool SubClauseNotEmpty
        {
            get
            {
                foreach (WhereCondition ic in List)
                {
                    if (ic.SubClauseNotEmpty)
                    {
                        return true;
                    }
                }
                return false;
            }
        }

        public void Add(WhereCondition ic)
		{
			List.Add( ic );
		}

		public WhereCondition this[int index]
		{
			get { return (WhereCondition)List[index]; }
			set { List[index] = value; }
		}

		public override string ToSqlText(DataParamterCollection dpc, DbDialect dd)
		{
			StringBuilder sb = new StringBuilder();
			foreach ( WhereCondition ic in List )
			{
                if (ic.SubClauseNotEmpty)
                {
                    sb.Append("(");
                    sb.Append(ic.ToSqlText(dpc, dd));
                    sb.Append(") ");
                    sb.Append(Condition);
                    sb.Append(" ");
                }
			}
			string s = sb.ToString();
			return ( s.Length > 5 ) ? s.Substring(0, s.Length - Condition.Length - 2) : "";
		}
	}
}

⌨️ 快捷键说明

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