-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathQueryInfo.cs
37 lines (30 loc) · 1.07 KB
/
QueryInfo.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
using System;
using System.Collections.Generic;
namespace SecurityDriven.TinyORM
{
using Utils;
public sealed class QueryInfo
{
public string SQL { get; set; }
public Dictionary<string, (object, Type)> ParameterMap { get; set; }
QueryInfo() { }
QueryInfo(string sql, Dictionary<string, (object, Type)> parameterMap)
{
this.SQL = sql;
this.ParameterMap = parameterMap;
}
public static QueryInfo Create(string sql) => Create<string>(sql, null);
public static QueryInfo Create<TParamType>(string sql, TParamType param) where TParamType : class
{
var queryInfo = new QueryInfo() { SQL = sql };
if (param == null)
{
queryInfo.ParameterMap = new Dictionary<string, (object, Type)>(0, StringComparer.Ordinal);
return queryInfo;
}
queryInfo.ParameterMap = ReflectionHelper_Shared.ObjectToDictionary_Parameterized<TParamType>(param);
return queryInfo;
}// Create<TParamType>()
public static QueryInfo Create(string sql, Dictionary<string, (object, Type)> parameterMap) => new QueryInfo(sql, parameterMap);
}// class QueryInfo
}// ns