Beispiel #1
0
            /// <summary>
            /// 将表达式转化为 TSQL 查询表达式字串
            /// </summary>
            public override string ToString()
            {
                string s = null;

                if (this.__Column == 0 && base.__Operate == SQLHelper.Operators.Custom)
                {
                    s = (string)base.__Value;                              //for full custom expression support
                }
                else
                {
                    switch (this.__Column)
                    {
                    case DI.dbo_uf_Split.id:
                        if (base.__Operate == SQLHelper.Operators.Custom)
                        {
                            s = "[id]" + (string)base.__Value;
                        }
                        else if (base.__Operate == SQLHelper.Operators.In || base.__Operate == SQLHelper.Operators.NotIn)
                        {
                            s = "[id] " + SQLHelper.GetOperater(base.__Operate) + " (" + SQLHelper.Combine <int>((IEnumerable <int>)base.__Value) + ")";
                        }
                        else
                        {
                            s = "[id] " + SQLHelper.GetOperater(base.__Operate) + " " + base.__Value.ToString();
                        }
                        break;

                    case DI.dbo_uf_Split.item:
                        if (base.__Operate == SQLHelper.Operators.Custom)
                        {
                            s = "[item]" + (string)base.__Value;
                        }
                        else if (base.__Operate == SQLHelper.Operators.In || base.__Operate == SQLHelper.Operators.NotIn)
                        {
                            s = "[item] " + SQLHelper.GetOperater(base.__Operate) + " (" + SQLHelper.Combine <string>((IEnumerable <string>)base.__Value) + ")";
                        }
                        else if (base.__Value == null && base.__Operate == SQLHelper.Operators.Equal)
                        {
                            s = "[item] IS NULL";
                        }
                        else if (base.__Value == null && base.__Operate == SQLHelper.Operators.NotEqual)
                        {
                            s = "[item] IS NOT NULL";
                        }
                        else if (base.__Operate == SQLHelper.Operators.Like)
                        {
                            s = "[item] LIKE '%" + SQLHelper.EscapeLike((string)base.__Value) + "%'";
                        }
                        else if (base.__Operate == SQLHelper.Operators.CustomLike)
                        {
                            s = "[item] LIKE '" + SQLHelper.EscapeEqual((string)base.__Value) + "'";
                        }
                        else if (base.__Operate == SQLHelper.Operators.NotLike)
                        {
                            s = "[item] NOT LIKE '%" + SQLHelper.EscapeLike((string)base.__Value) + "%'";
                        }
                        else if (base.__Operate == SQLHelper.Operators.CustomNotLike)
                        {
                            s = "[item] NOT LIKE '" + SQLHelper.EscapeEqual((string)base.__Value) + "'";
                        }
                        else
                        {
                            s = "[item] " + SQLHelper.GetOperater(base.__Operate) + " '" + SQLHelper.EscapeEqual((string)base.__Value) + "'";
                        }
                        break;
                    }
                }
                if (this.__Nodes != null && this.__Nodes.Count > 0)
                {
                    s = "(" + s;
                    foreach (dbo_uf_Split __node in this.__Nodes)
                    {
                        s += " " + (this.__IsAndEffect ? "AND" : "OR") + " " + __node.ToString();
                    }
                    s += ")";
                }
                return(s);
            }