Esempio n. 1
0
        private static OrderCriteriaField CreateField(string sourceAndFieldName, SortDirection sortDirection)
        {
            //string source = null;
            string[]           parts              = sourceAndFieldName.Trim().Split('.');
            string             fieldName          = parts[parts.Length - 1];
            Source             source             = Source.FromString(String.Join(".", parts, 0, parts.Length - 1));
            OrderCriteriaField orderCriteriaField = new OrderCriteriaField(fieldName, fieldName, source, sortDirection);

            return(orderCriteriaField);
        }
Esempio n. 2
0
        ///<summary>
        ///Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        ///</summary>
        ///
        ///<returns>
        ///true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        ///</returns>
        ///
        ///<param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>. </param><filterpriority>2</filterpriority>
        public override bool Equals(object obj)
        {
            if (!(obj is OrderCriteriaField))
            {
                return(false);
            }
            OrderCriteriaField objOrderCriteriaField = obj as OrderCriteriaField;

            return(this.PropertyName.Equals(objOrderCriteriaField.PropertyName) && _sortDirection.Equals(objOrderCriteriaField.SortDirection));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an OrderCriteria object by parsing a string in the correct format.
        /// The format is:
        /// <para>&lt;orderCriteria&gt; => &lt;emptystring&gt; | &lt;field&gt; [, &lt;field&gt;, ... ] <br/>
        /// &lt;field&gt; => &lt;fieldName&gt; [ ASC | DESC ] </para>
        /// For example: <code>Surname, Age DESC</code> or <code>Age ASC, Surname DESC</code>
        /// </summary>
        /// <param name="orderCriteriaString">The string in the correct format (see above)</param>
        /// <returns>An OrderCriteria created from the string</returns>
        public static IOrderCriteria FromString(string orderCriteriaString)
        {
            IOrderCriteria orderCriteria = new OrderCriteria();

            if (string.IsNullOrEmpty(orderCriteriaString))
            {
                return(orderCriteria);
            }
            orderCriteriaString = orderCriteriaString.Trim();
            if (string.IsNullOrEmpty(orderCriteriaString))
            {
                return(orderCriteria);
            }
            string[] orderFields = orderCriteriaString.Split(',');
            foreach (string field in orderFields)
            {
                orderCriteria.Add(OrderCriteriaField.FromString(field));
            }
            return(orderCriteria);
        }