Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
43 lines (37 loc) · 1.85 KB

File metadata and controls

43 lines (37 loc) · 1.85 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
using System.Collections.Generic;
using System.Linq;
namespace Simple.Data
{
public class ExpressionHelper
{
public static SimpleExpression CriteriaDictionaryToExpression(string tableName, IEnumerable<KeyValuePair<string, object>> dictionary)
{
if (dictionary.Count() == 1)
{
return CriteriaPairToExpression(tableName, dictionary.Single());
}
return new SimpleExpression(CriteriaPairToExpression(tableName, dictionary.First()),
CriteriaDictionaryToExpression(tableName, dictionary.Skip(1)),
SimpleExpressionType.And);
}
public static SimpleExpression CriteriaDictionaryToExpression(ObjectReference table, IEnumerable<KeyValuePair<string, object>> dictionary)
{
var list = dictionary.ToList();
if (list.Count == 1)
{
return CriteriaPairToExpression(table, list[0]);
}
return new SimpleExpression(CriteriaPairToExpression(table, list[0]),
CriteriaDictionaryToExpression(table, list.Skip(1)),
SimpleExpressionType.And);
}
private static SimpleExpression CriteriaPairToExpression(string tableName, KeyValuePair<string, object> pair)
{
return new SimpleExpression(new ObjectReference(pair.Key, new ObjectReference(tableName)), pair.Value, SimpleExpressionType.Equal);
}
private static SimpleExpression CriteriaPairToExpression(ObjectReference table, KeyValuePair<string, object> pair)
{
return new SimpleExpression(new ObjectReference(pair.Key, table), pair.Value, SimpleExpressionType.Equal);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.