forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIQuery.cs
More file actions
118 lines (95 loc) · 3.44 KB
/
IQuery.cs
File metadata and controls
118 lines (95 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace ServiceStack
{
//Interfaces and DTO's used in AutoQuery
public interface IQuery : IMeta
{
int? Skip { get; set; }
int? Take { get; set; }
string OrderBy { get; set; }
string OrderByDesc { get; set; }
string Include { get; set; }
}
public interface IQuery<From> : IQuery { }
public interface IQuery<From,Into> : IQuery { }
public interface IJoin { }
public interface IJoin<Source, Join1> : IJoin { }
public interface IJoin<Source, Join1, Join2> : IJoin { }
public interface IJoin<Source, Join1, Join2, Join3> : IJoin { }
public interface IJoin<Source, Join1, Join2, Join3, Join4> : IJoin { }
public interface ILeftJoin<Source, Join1> : IJoin { }
public interface ILeftJoin<Source, Join1, Join2> : IJoin { }
public interface ILeftJoin<Source, Join1, Join2, Join3> : IJoin { }
public interface ILeftJoin<Source, Join1, Join2, Join3, Join4> : IJoin { }
public enum QueryTerm
{
Default = 0,
And = 1,
Or = 2,
}
public enum ValueStyle
{
Single = 0,
Multiple = 1,
List = 2,
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class QueryAttribute : AttributeBase
{
public QueryAttribute() {}
public QueryAttribute(QueryTerm defaultTerm)
{
DefaultTerm = defaultTerm;
}
public QueryTerm DefaultTerm { get; set; }
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class QueryFieldAttribute : AttributeBase
{
public QueryTerm Term { get; set; }
public string Operand { get; set; }
public string Template { get; set; }
public string Field { get; set; }
public string ValueFormat { get; set; }
public ValueStyle ValueStyle { get; set; }
public int ValueArity { get; set; }
}
public abstract class QueryBase : IQuery
{
[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 Dictionary<string, string> Meta { get; set; }
}
public abstract class QueryBase<T> : QueryBase, IQuery<T>, IReturn<QueryResponse<T>> { }
public abstract class QueryBase<From, Into> : QueryBase, IQuery<From, Into>, IReturn<QueryResponse<Into>> { }
public interface IQueryResponse : IHasResponseStatus, IMeta
{
int Offset { get; set; }
int Total { get; set; }
}
[DataContract]
public class QueryResponse<T> : IQueryResponse
{
[DataMember(Order = 1)]
public virtual int Offset { get; set; }
[DataMember(Order = 2)]
public virtual int Total { get; set; }
[DataMember(Order = 3)]
public virtual List<T> Results { get; set; }
[DataMember(Order = 4)]
public virtual Dictionary<string, string> Meta { get; set; }
[DataMember(Order = 5)]
public virtual ResponseStatus ResponseStatus { get; set; }
}
}