using System;
using System.Linq;
using System.Runtime.Serialization;

/// <summary>
/// Represents a sort expression of Kendo DataSource.
/// </summary>
[DataContract]
public class Sort
{
    /// <summary>
    /// Gets or sets the name of the sorted field (property).
    /// </summary>
    [DataMember(Name="field")]
    public string Field { get; set; }

    /// <summary>
    /// Gets or sets the sort direction. Should be either "asc" or "desc".
    /// </summary>
    [DataMember(Name="dir")]
    public string Dir { get; set; }

    /// <summary>
    /// Converts to form required by Dynamic Linq e.g. "Field1 desc"
    /// </summary>
    public string ToExpression()
    {
        return Field + " " + Dir;
    }
}