Skip to content

Simple.OData.Client fluent API

object edited this page Feb 12, 2013 · 9 revisions

Simple.OData.Client has two APIs that can be used to retrieve and modify OData resources: basic and fluent. Each of APIs provides full set of OData protocol operations, so choice of the API depends on client application design and personal developer's preferences. Fluent API consists of methods that can be chained to form parts of OData HTTP request. These methods are defined on an interface ICommand that is accessed from an ODataClient instance by calling For(<collectionName>). Each fluent method has return value of IClientWithCommand which is derived from ICommand and therefore can be used for further method chaining.

Here is a definition of ICommand interface:

public interface ICommand
{
    IClientWithCommand For(string collectionName);
    IClientWithCommand As(string derivedCollectionName);
    IClientWithCommand Key(params object[] entryKey);
    IClientWithCommand Key(IEnumerable<object> entryKey);
    IClientWithCommand Key(IDictionary<string, object> entryKey);
    IClientWithCommand Filter(string filter);
    IClientWithCommand Filter(FilterExpression expression);
    IClientWithCommand Skip(int count);
    IClientWithCommand Top(int count);
    IClientWithCommand Expand(IEnumerable<string> associations);
    IClientWithCommand Expand(params string[] associations);
    IClientWithCommand Select(IEnumerable<string> columns);
    IClientWithCommand Select(params string[] columns);
    IClientWithCommand OrderBy(IEnumerable<KeyValuePair<string, bool>> columns);
    IClientWithCommand OrderBy(params string[] columns);
    IClientWithCommand OrderByDescending(params string[] columns);
    IClientWithCommand Count();
    IClientWithCommand NavigateTo(string linkName);
    IClientWithCommand Set(object value);
    IClientWithCommand Set(IDictionary<string, object> value);
    IClientWithCommand Function(string functionName);
    IClientWithCommand Parameters(IDictionary<string, object> parameters);
}