forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetMultiplePredicate.cs
48 lines (42 loc) · 1.3 KB
/
GetMultiplePredicate.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DapperExtensions
{
public class GetMultiplePredicate
{
private readonly List<GetMultiplePredicateItem> _items;
public GetMultiplePredicate()
{
_items = new List<GetMultiplePredicateItem>();
}
public IEnumerable<GetMultiplePredicateItem> Items
{
get { return _items.AsReadOnly(); }
}
public void Add<T>(IPredicate predicate, IList<ISort> sort = null) where T : class
{
_items.Add(new GetMultiplePredicateItem
{
Value = predicate,
Type = typeof(T),
Sort = sort
});
}
public void Add<T>(object id) where T : class
{
_items.Add(new GetMultiplePredicateItem
{
Value = id,
Type = typeof (T)
});
}
public class GetMultiplePredicateItem
{
public object Value { get; set; }
public Type Type { get; set; }
public IList<ISort> Sort { get; set; }
}
}
}