forked from hez2010/TypedSql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoSchema.cs
More file actions
129 lines (102 loc) · 4.53 KB
/
Copy pathDemoSchema.cs
File metadata and controls
129 lines (102 loc) · 4.53 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
119
120
121
122
123
124
125
126
127
128
129
using System.Runtime.CompilerServices;
using TypedSql.Runtime;
namespace TypedSql;
internal readonly struct PersonIdColumn : IColumn<Person, int>
{
public static string Identifier => "id";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Get(in Person row) => row.Id;
}
internal readonly struct PersonNameColumn : IColumn<Person, string>
{
public static string Identifier => "name";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Get(in Person row) => row.Name;
}
internal readonly struct PersonAgeColumn : IColumn<Person, int>
{
public static string Identifier => "age";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Get(in Person row) => row.Age;
}
internal readonly struct PersonCityColumn : IColumn<Person, string>
{
public static string Identifier => "city";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Get(in Person row) => row.City;
}
internal readonly struct PersonSalaryColumn : IColumn<Person, float>
{
public static string Identifier => "salary";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Get(in Person row) => row.Salary;
}
internal readonly struct PersonDepartmentColumn : IColumn<Person, string>
{
public static string Identifier => "department";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Get(in Person row) => row.Department;
}
internal readonly struct PersonIsManagerColumn : IColumn<Person, bool>
{
public static string Identifier => "isManager";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Get(in Person row) => row.IsManager;
}
internal readonly struct PersonYearsAtCompanyColumn : IColumn<Person, int>
{
public static string Identifier => "yearsAtCompany";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Get(in Person row) => row.YearsAtCompany;
}
internal readonly struct PersonCountryColumn : IColumn<Person, string>
{
public static string Identifier => "country";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Get(in Person row) => row.Country;
}
internal readonly struct PersonTeamColumn : IColumn<Person, string?>
{
public static string Identifier => "team";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string? Get(in Person row) => row.Team;
}
internal readonly struct PersonLevelColumn : IColumn<Person, string>
{
public static string Identifier => "level";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Get(in Person row) => row.Level;
}
internal static class DemoSchema
{
public static readonly IReadOnlyDictionary<string, ColumnMetadata> People = CreatePeople();
private static IReadOnlyDictionary<string, ColumnMetadata> CreatePeople()
{
return new Dictionary<string, ColumnMetadata>(StringComparer.OrdinalIgnoreCase)
{
[PersonIdColumn.Identifier] = new(PersonIdColumn.Identifier, typeof(PersonIdColumn), typeof(int)),
[PersonNameColumn.Identifier] = new(PersonNameColumn.Identifier, typeof(PersonNameColumn), typeof(string)),
[PersonAgeColumn.Identifier] = new(PersonAgeColumn.Identifier, typeof(PersonAgeColumn), typeof(int)),
[PersonCityColumn.Identifier] = new(PersonCityColumn.Identifier, typeof(PersonCityColumn), typeof(string)),
[PersonSalaryColumn.Identifier] = new(PersonSalaryColumn.Identifier, typeof(PersonSalaryColumn), typeof(float)),
[PersonDepartmentColumn.Identifier] = new(PersonDepartmentColumn.Identifier, typeof(PersonDepartmentColumn), typeof(string)),
[PersonIsManagerColumn.Identifier] = new(PersonIsManagerColumn.Identifier, typeof(PersonIsManagerColumn), typeof(bool)),
[PersonYearsAtCompanyColumn.Identifier] = new(PersonYearsAtCompanyColumn.Identifier, typeof(PersonYearsAtCompanyColumn), typeof(int)),
[PersonCountryColumn.Identifier] = new(PersonCountryColumn.Identifier, typeof(PersonCountryColumn), typeof(string)),
[PersonTeamColumn.Identifier] = new(PersonTeamColumn.Identifier, typeof(PersonTeamColumn), typeof(string)),
[PersonLevelColumn.Identifier] = new(PersonLevelColumn.Identifier, typeof(PersonLevelColumn), typeof(string)),
};
}
}
public record struct Person(
int Id,
string Name,
int Age,
string City,
float Salary,
string Department,
bool IsManager,
int YearsAtCompany,
string Country,
string? Team,
string Level);