/// <summary>
        /// Binds the order by query option to the sql builder.
        /// </summary>
        /// <param name="orderByQueryOption">The order by query.</param>
        /// <param name="objectInfo">The IObjectInfo for the type to bind the order by list for.</param>
        /// <param name="orderBySqlBuilder">The order by SQL builder.</param>
        /// <returns>The SqlBuilder after the order by clause has been added.</returns>
        public static IOrderBy BindOrderBy(OrderByQueryOption orderByQueryOption, IObjectInfo objectInfo, IOrderBy orderBySqlBuilder)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            if (orderBySqlBuilder == null)
            {
                throw new ArgumentNullException("orderBySqlBuilder");
            }

            if (orderByQueryOption != null)
            {
                for (int i = 0; i < orderByQueryOption.Properties.Count; i++)
                {
                    var property = orderByQueryOption.Properties[i];
                    var column = objectInfo.TableInfo.GetColumnInfoForProperty(property.Name);

                    if (column == null)
                    {
                        throw new ODataException(string.Format(CultureInfo.InvariantCulture, Messages.InvalidPropertyName, objectInfo.ForType.Name, property.Name));
                    }

                    var columnName = column.ColumnName;

                    if (property.Direction == OrderByDirection.Ascending)
                    {
                        orderBySqlBuilder.OrderByAscending(columnName);
                    }
                    else
                    {
                        orderBySqlBuilder.OrderByDescending(columnName);
                    }
                }
            }

            return orderBySqlBuilder;
        }
 public WhenConstructedWithASingleValue()
 {
     this.rawValue = "$orderby=Name";
     this.option = new OrderByQueryOption(this.rawValue);
 }
 public WhenConstructedWithAMultipleValues()
 {
     this.rawValue = "$orderby=Name,Age desc";
     this.option = new OrderByQueryOption(this.rawValue);
 }