public static IEnumerable <T> Query <T>(this IDataService service, DataPage page,
                                                Action <IQueryBuilder <T> > queryBuilder,
                                                Action <IProjection <T> > fieldSelection, string orderBy, bool asc) where T : ITable, new()
        {
            var query = new QueryBuilder <T>();

            queryBuilder(query);

            var projection = new Projection <T>();

            fieldSelection(projection);

            XmlRpcStruct data = query.Dictionary.AsXmlRpcStruct();

            string[] selectedFields = projection.Build();

            var configuration          = service.Configuration;
            var methodListenerProvider = service.MethodListenerProvider;
            var wrapper = new CustomDataServiceWrapper(configuration, methodListenerProvider);

            if (String.IsNullOrEmpty(orderBy))
            {
                return(wrapper.Invoke <IEnumerable <object>, T[]>(d => d.Query(configuration.GetApiKey(),
                                                                               typeof(T).Name, page.Size,
                                                                               page.Number, data, selectedFields)));
            }
            else
            {
                return(wrapper.Invoke <IEnumerable <object>, T[]>(d => d.Query(configuration.GetApiKey(),
                                                                               typeof(T).Name, page.Size,
                                                                               page.Number, data, selectedFields, orderBy, asc)));
            }
        }
        public static T Load <T>(this IDataService service, int id, Action <IProjection <T> > projection)
            where T : class, ITable, new()
        {
            var fieldSelection = new Projection <T>();

            projection(fieldSelection);

            var wrapper = new CustomDataServiceWrapper(service.Configuration, service.MethodListenerProvider);

            return
                (wrapper.Invoke <object, T>(d => d.Load(service.Configuration.GetApiKey(), typeof(T).Name, id, fieldSelection.Build())));
        }
        public static IEnumerable <T> FindByField <T>(this IDataService service, DataPage page,
                                                      Action <IFieldQuery <T> > query,
                                                      Action <IProjection <T> > fieldSelection)
            where T : ITable, new()
        {
            var fieldQuery = new FieldQuery <T>();

            query(fieldQuery);

            var projection = new Projection <T>();

            fieldSelection(projection);

            var wrapper = new CustomDataServiceWrapper(service.Configuration, service.MethodListenerProvider);

            return(wrapper.Invoke <IEnumerable <object>, T[]>(d => d.FindByField(service.Configuration.GetApiKey(),
                                                                                 typeof(T).Name, page.Size,
                                                                                 page.Number,
                                                                                 fieldQuery.Name,
                                                                                 fieldQuery.Value,
                                                                                 projection.Build())));
        }