-
-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathStaticHelper.cs
More file actions
81 lines (65 loc) · 2.28 KB
/
StaticHelper.cs
File metadata and controls
81 lines (65 loc) · 2.28 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
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
using System.Linq.Expressions;
namespace System.Linq.Dynamic.Core.Tests
{
public static class StaticHelper
{
public static Guid NewStaticGuid => new("43b17e59-2b66-4697-a3ab-7b45baedee72");
public static class Nested
{
public static Guid NewNestedStaticProperty => new("954692b3-6a37-4c9c-ad55-07fbb593f046");
public static Guid NewNestedStaticMethod() => new ("954692b3-6a37-4c9c-ad55-07fbb593f046");
public static bool IsNull(object? value) => value != null;
}
public static Guid? GetGuid(string name)
{
return Guid.NewGuid();
}
public static string Filter(string filter)
{
return filter;
}
public static StaticHelperSqlExpression SubSelect(string columnName, string objectClassName, string? filter, string order)
{
Expression<Func<User, bool>>? expFilter = null;
if (filter != null)
{
var config = new ParsingConfig
{
CustomTypeProvider = new TestCustomTypeProvider()
};
expFilter = DynamicExpressionParser.ParseLambda<User, bool>(config, true, filter);
}
return new StaticHelperSqlExpression
{
Filter = expFilter
};
}
public static bool In(Guid? value, StaticHelperSqlExpression expression)
{
return value != Guid.Empty;
}
public static Guid First(StaticHelperSqlExpression staticHelperSqlExpression)
{
return Guid.NewGuid();
}
public static string ToExpressionString(Guid? value, int subQueryLevel)
{
if (value == null)
{
return "NULL";
}
var quote = GetQuote(subQueryLevel);
return $"Guid.Parse({quote}{value}{quote})";
}
public static Guid Get(string settingName)
{
return Guid.NewGuid();
}
private static string GetQuote(int subQueryLevel)
{
var quoteCount = (int)Math.Pow(2, subQueryLevel - 1);
return new string('"', quoteCount);
}
}
}