Exemple #1
0
        /// <summary>
        /// 去掉的表前缀
        /// </summary>
        /// <returns></returns>
        public OrderByClip RemovePrefixTableName()
        {
            OrderByClip tempOrderByClip = new OrderByClip();

            foreach (KeyValuePair <string, OrderByType> kv in this.orderByClip)
            {
                string keyName = kv.Key;
                if (kv.Key.IndexOf('.') > 0)
                {
                    keyName = keyName.Substring(keyName.IndexOf('.') + 1);
                }

                tempOrderByClip.orderByClip.Add(keyName, kv.Value);
            }

            return(tempOrderByClip);
        }
Exemple #2
0
 private static OrderByClip ToOrderByClipChild(System.Linq.Expressions.Expression exprBody, OrderByType orderBy)
 {
     if (exprBody is MemberExpression)
     {
         var         e  = (MemberExpression)exprBody;
         OrderByClip gb = OrderByClip.None;
         if (orderBy == OrderByType.DESC)
         {
             gb = gb && new Field(e.Member.Name, e.Expression.Type).Desc;
         }
         else
         {
             gb = gb && new Field(e.Member.Name, e.Expression.Type).Asc;
         }
         return(gb);
     }
     if (exprBody is NewExpression)
     {
         var         exNew = (NewExpression)exprBody;
         var         type  = exNew.Constructor.DeclaringType;
         var         list  = new List <string>(exNew.Arguments.Count);
         OrderByClip gb    = OrderByClip.None;
         foreach (MemberExpression member in exNew.Arguments)
         {
             if (orderBy == OrderByType.DESC)
             {
                 gb = gb && new Field(member.Member.Name, member.Expression.Type).Desc;
             }
             else
             {
                 gb = gb && new Field(member.Member.Name, member.Expression.Type).Asc;
             }
         }
         return(gb);
     }
     if (exprBody is UnaryExpression)
     {
         var ueEx = (UnaryExpression)exprBody;
         return(ToOrderByClipChild(ueEx.Operand, orderBy));
     }
     throw new Exception("暂时不支持的Order by lambda写法!请使用经典写法!");
 }