using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using Test.ServiceInterface;
using Test.ServiceModel;
using Test.ServiceModel.Types;
namespace ServiceStack
{
[DataContract]
public partial class QueryBase
{
public QueryBase()
{
Meta = new Dictionary<string, string>{};
}
[DataMember(Order=1)]
public virtual int? Skip { get; set; }
[DataMember(Order=2)]
public virtual int? Take { get; set; }
[DataMember(Order=3)]
public virtual string OrderBy { get; set; }
[DataMember(Order=4)]
public virtual string OrderByDesc { get; set; }
[DataMember(Order=5)]
public virtual string Include { get; set; }
[DataMember(Order=6)]
public virtual string Fields { get; set; }
[DataMember(Order=7)]
public virtual Dictionary<string, string> Meta { get; set; }
}
public partial class QueryDb<From, Into>
: QueryBase
{
}
[DataContract]
public partial class QueryResponse<T>
{
public QueryResponse()
{
Results = new List<Poco>{};
Meta = new Dictionary<string, string>{};
}
[DataMember(Order=1)]
public virtual int Offset { get; set; }
[DataMember(Order=2)]
public virtual int Total { get; set; }
[DataMember(Order=3)]
public virtual List<Poco> Results { get; set; }
[DataMember(Order=4)]
public virtual Dictionary<string, string> Meta { get; set; }
[DataMember(Order=5)]
public virtual ResponseStatus ResponseStatus { get; set; }
}
}
namespace Test.ServiceInterface
{
public partial class QueryItems
: QueryDb<Item, Poco>
{
}
}
namespace Test.ServiceModel
{
public partial class Item
{
public virtual string Name { get; set; }
public virtual string Description { get; set; }
}
}
namespace Test.ServiceModel.Types
{
public partial class Poco
{
public virtual string Name { get; set; }
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/reply/QueryItems HTTP/1.1
Host: test.servicestack.net
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"offset":0,"total":0,"results":[{"name":"String"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}