コード例 #1
0
        private static GroupByClip ToGroupByClipChild(System.Linq.Expressions.Expression exprBody)
        {
            if (exprBody is MemberExpression)
            {
                var e = (MemberExpression)exprBody;
                return(new GroupByClip(new Field(e.Member.Name, e.Expression.Type.Name)));
            }
            if (exprBody is NewExpression)
            {
                var         exNew = (NewExpression)exprBody;
                var         type  = exNew.Constructor.DeclaringType;
                var         list  = new List <string>(exNew.Arguments.Count);
                GroupByClip gb    = GroupByClip.None;
                foreach (MemberExpression member in exNew.Arguments)
                {
                    gb = gb && new Field(member.Member.Name, member.Expression.Type.Name).GroupBy;
                }
                return(gb);
            }
            if (exprBody is UnaryExpression)
            {
                var exNew = (UnaryExpression)exprBody;
                return(ToGroupByClipChild(exNew.Operand));
                //var type = exNew.Constructor.DeclaringType;
                //var list = new List<string>(exNew.Arguments.Count);
                //GroupByClip gb = GroupByClip.None;
                //foreach (MemberExpression member in exNew.Arguments)
                //{
                //    gb = gb && new Field(member.Member.Name, member.Expression.Type.Name).GroupBy;
                //}
                //return gb;
            }

            throw new Exception("暂时不支持的Group by lambda写法!请使用经典写法!");
        }
コード例 #2
0
ファイル: GroupByClip.cs プロジェクト: lsysunbow/Dos.ORM
        /// <summary>
        /// 去掉的表前缀
        /// </summary>
        /// <returns></returns>
        public GroupByClip RemovePrefixTableName()
        {
            GroupByClip groupc = new GroupByClip(this.groupByClip);

            if (string.IsNullOrEmpty(groupc.groupByClip))
                return groupc;

            StringBuilder gstring = new StringBuilder();
            string[] fs = groupc.groupByClip.Split(',');
            foreach (string s in fs)
            {
                if (string.IsNullOrEmpty(s))
                    continue;

                gstring.Append(",");
                if (s.IndexOf('.') > 0)
                    gstring.Append(s.Substring(s.IndexOf('.') + 1));
                else
                    gstring.Append(s);
            }

            if (gstring.Length > 1)
                groupc.groupByClip = gstring.ToString().Substring(1);
            else
                groupc.groupByClip = gstring.ToString();

            return groupc;

        }
コード例 #3
0
ファイル: GroupByClip.cs プロジェクト: hargenhz/Dos.ORM
 /// <summary>
 /// 判断 GroupByClip  是否为null
 /// </summary>
 /// <param name="groupByClip"></param>
 /// <returns></returns>
 public static bool IsNullOrEmpty(GroupByClip groupByClip)
 {
     if ((null == groupByClip) || string.IsNullOrEmpty(groupByClip.ToString()))
     {
         return(true);
     }
     return(false);
 }
コード例 #4
0
ファイル: GroupByClip.cs プロジェクト: hargenhz/Dos.ORM
        /// <summary>
        /// 比较
        /// </summary>
        /// <param name="groupByClip"></param>
        /// <returns></returns>
        public bool Equals(GroupByClip groupByClip)
        {
            if (null == groupByClip)
            {
                return(false);
            }

            return(this.ToString().Equals(groupByClip.ToString()));
        }
コード例 #5
0
ファイル: GroupByClip.cs プロジェクト: hargenhz/Dos.ORM
        /// <summary>
        /// 去掉的表前缀
        /// </summary>
        /// <returns></returns>
        public GroupByClip RemovePrefixTableName()
        {
            GroupByClip groupc = new GroupByClip(this.groupByClip);

            if (string.IsNullOrEmpty(groupc.groupByClip))
            {
                return(groupc);
            }

            StringBuilder gstring = new StringBuilder();

            string[] fs = groupc.groupByClip.Split(',');
            foreach (string s in fs)
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                gstring.Append(",");
                if (s.IndexOf('.') > 0)
                {
                    gstring.Append(s.Substring(s.IndexOf('.') + 1));
                }
                else
                {
                    gstring.Append(s);
                }
            }

            if (gstring.Length > 1)
            {
                groupc.groupByClip = gstring.ToString().Substring(1);
            }
            else
            {
                groupc.groupByClip = gstring.ToString();
            }

            return(groupc);
        }
コード例 #6
0
ファイル: GroupByClip.cs プロジェクト: lsysunbow/Dos.ORM
 /// <summary>
 /// 判断 GroupByClip  是否为null
 /// </summary>
 /// <param name="groupByClip"></param>
 /// <returns></returns>
 public static bool IsNullOrEmpty(GroupByClip groupByClip)
 {
     if ((null == groupByClip) || string.IsNullOrEmpty(groupByClip.ToString()))
         return true;
     return false;
 }
コード例 #7
0
ファイル: GroupByClip.cs プロジェクト: lsysunbow/Dos.ORM
        /// <summary>
        /// 比较
        /// </summary>
        /// <param name="groupByClip"></param>
        /// <returns></returns>
        public bool Equals(GroupByClip groupByClip)
        {
            if (null == groupByClip)
                return false;

            return this.ToString().Equals(groupByClip.ToString());
        }