/// <summary> /// 比较 /// </summary> /// <param name="orderByClip"></param> /// <returns></returns> public bool Equals(OrderByClip orderByClip) { if (null == orderByClip) { return(false); } return(this.ToString().Equals(orderByClip.ToString())); }
/// <summary> /// 判断 OrderByClip 是否为null /// </summary> /// <param name="orderByClip"></param> /// <returns></returns> public static bool IsNullOrEmpty(OrderByClip orderByClip) { if ((null == orderByClip) || string.IsNullOrEmpty(orderByClip.ToString())) { return(true); } return(false); }
/// <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); }
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写法!请使用经典写法!"); }