-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathContactCdc.cs
More file actions
199 lines (165 loc) · 8.68 KB
/
Copy pathContactCdc.cs
File metadata and controls
199 lines (165 loc) · 8.68 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
* This file is automatically generated; any changes will be lost.
*/
namespace SqlServerSidecarDemo.Publisher.Entities;
/// <summary>
/// Represents the CDC model for the root (parent) database table '[Legacy].[Contact]'.
/// </summary>
public partial class ContactCdc : IEntity, IPartitionKey, IGlobalIdentifier<string?>, ILinkIdentifierMapping<string>
{
/// <inheritdoc/>
[JsonPropertyName("globalId")]
public string? GlobalId { get; set; }
/// <summary>
/// Gets or sets the CID '[Legacy].[Contact].[ContactId]' column value.
/// </summary>
[JsonIgnore]
public int CID { get; set; }
/// <summary>
/// Gets or sets the Name '[Legacy].[Contact].[Name]' column value.
/// </summary>
[JsonPropertyName("name")]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the Phone '[Legacy].[Contact].[Phone]' column value.
/// </summary>
[JsonPropertyName("phone")]
public string? Phone { get; set; }
/// <summary>
/// Gets or sets the Email '[Legacy].[Contact].[Email]' column value.
/// </summary>
[JsonPropertyName("email")]
public string? Email { get; set; }
/// <summary>
/// Gets or sets the Active '[Legacy].[Contact].[Active]' column value.
/// </summary>
[JsonPropertyName("active")]
public bool? Active { get; set; }
/// <summary>
/// Gets or sets the Dont Call List '[Legacy].[Contact].[DontCallList]' column value.
/// </summary>
[JsonPropertyName("dontCallList")]
public bool? DontCallList { get; set; }
/// <summary>
/// Gets or sets the Address Id '[Legacy].[Contact].[AddressId]' column value.
/// </summary>
[JsonPropertyName("addressId")]
public int? AddressId { get; set; }
/// <summary>
/// Gets or sets the Alternate Contact Id '[Legacy].[Contact].[AlternateContactId]' column value.
/// </summary>
[JsonIgnore]
public int? AlternateContactId { get; set; }
/// <summary>
/// Gets or sets the Global Alternate Contact Id '[Legacy].[Contact].[AlternateContactId]' mapped identifier value.
/// </summary>
[JsonPropertyName("globalAlternateContactId")]
public string? GlobalAlternateContactId { get; set; }
/// <summary>
/// Gets or sets the Unique Id column value (left join table '[Legacy].[ContactMapping].[UniqueId]').
/// </summary>
[JsonPropertyName("uniqueId")]
public Guid UniqueId { get; set; }
/// <summary>
/// Gets or sets the related (one-to-one) <see cref="ContactCdc.Address"/> (database table '[Legacy].[Address]').
/// </summary>
[JsonPropertyName("address")]
public ContactCdc.AddressCdc? Address { get; set; }
/// <inheritdoc/>
[JsonPropertyName("etag")]
public string? ETag { get; set; }
/// <inheritdoc/>
[JsonIgnore]
public CompositeKey PrimaryKey => new(GlobalId);
/// <inheritdoc/>
[JsonIgnore]
public string? PartitionKey => "Contact";
/// <inheritdoc/>
[JsonIgnore]
public CompositeKey TableKey => new(CID);
/// <inheritdoc/>
public void GetIdentifierMappingConfigurations(ValueIdentifierMappingCollection<string> coll)
{
coll.Add(new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalId), Schema = "Legacy", Table = "Contact", Key = TableKey.ToString() });
coll.Add(new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalAlternateContactId), Schema = "Legacy", Table = "Contact", Key = AlternateContactId.ToString() });
Address?.GetIdentifierMappingConfigurations(coll);
}
/// <inheritdoc/>
public async Task LinkIdentifierMappingsAsync(ValueIdentifierMappingCollection<string> coll, IIdentifierGenerator<string> idGen)
{
await coll.AddAsync(GlobalId == default, async () => new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalId), Schema = "Legacy", Table = "Contact", Key = TableKey.ToString(), GlobalId = await idGen.GenerateIdentifierAsync<ContactCdc>().ConfigureAwait(false) }).ConfigureAwait(false);
await coll.AddAsync(GlobalAlternateContactId == default && AlternateContactId != default, async () => new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalAlternateContactId), Schema = "Legacy", Table = "Contact", Key = AlternateContactId.ToString(), GlobalId = await idGen.GenerateIdentifierAsync<ContactCdc>().ConfigureAwait(false) }).ConfigureAwait(false);
await (Address?.LinkIdentifierMappingsAsync(coll, idGen) ?? Task.CompletedTask).ConfigureAwait(false);
}
/// <inheritdoc/>
public void RelinkIdentifierMappings(ValueIdentifierMappingCollection<string> coll)
{
coll.Invoke(GlobalId == default, () => GlobalId = coll.GetGlobalId(this, nameof(GlobalId)));
coll.Invoke(GlobalAlternateContactId == default && AlternateContactId != default, () => GlobalAlternateContactId = coll.GetGlobalId(this, nameof(GlobalAlternateContactId)));
Address?.RelinkIdentifierMappings(coll);
}
#region AddressCdc
/// <summary>
/// Represents the CDC model for the related (child) database table '[Legacy].[Address]' (known uniquely as 'Address').
/// </summary>
public partial class AddressCdc : IPrimaryKey, IGlobalIdentifier<string?>, ILinkIdentifierMapping<string>
{
/// <inheritdoc/>
[JsonPropertyName("globalId")]
public string? GlobalId { get; set; }
/// <summary>
/// Gets or sets the AID '[Legacy].[Address].[AddressId]' column value. This column is used within the join.
/// </summary>
[JsonIgnore]
public int AID { get; set; }
/// <summary>
/// Gets or sets the Street1 '[Legacy].[Address].[Street1]' column value.
/// </summary>
[JsonPropertyName("street1")]
public string? Street1 { get; set; }
/// <summary>
/// Gets or sets the Street2 '[Legacy].[Address].[Street2]' column value.
/// </summary>
[JsonPropertyName("street2")]
public string? Street2 { get; set; }
/// <summary>
/// Gets or sets the Alternate Address Id '[Legacy].[Address].[AlternateAddressId]' column value.
/// </summary>
[JsonIgnore]
public int? AlternateAddressId { get; set; }
/// <summary>
/// Gets or sets the Global Alternate Address Id '[Legacy].[Address].[AlternateAddressId]' mapped identifier value.
/// </summary>
[JsonPropertyName("globalAlternateAddressId")]
public string? GlobalAlternateAddressId { get; set; }
/// <inheritdoc/>
[JsonIgnore]
public CompositeKey PrimaryKey => new(AID);
/// <inheritdoc/>
[JsonIgnore]
public CompositeKey TableKey => new(AID);
/// <inheritdoc/>
public void GetIdentifierMappingConfigurations(ValueIdentifierMappingCollection<string> coll)
{
coll.Add(new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalId), Schema = "Legacy", Table = "Address", Key = TableKey.ToString() });
coll.Add(new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalAlternateAddressId), Schema = "Legacy", Table = "Address", Key = AlternateAddressId.ToString() });
}
/// <inheritdoc/>
public async Task LinkIdentifierMappingsAsync(ValueIdentifierMappingCollection<string> coll, IIdentifierGenerator<string> idGen)
{
await coll.AddAsync(GlobalId == default, async () => new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalId), Schema = "Legacy", Table = "Address", Key = TableKey.ToString(), GlobalId = await idGen.GenerateIdentifierAsync<AddressCdc>().ConfigureAwait(false) }).ConfigureAwait(false);
await coll.AddAsync(GlobalAlternateAddressId == default && AlternateAddressId != default, async () => new ValueIdentifierMapping<string> { Value = this, Property = nameof(GlobalAlternateAddressId), Schema = "Legacy", Table = "Address", Key = AlternateAddressId.ToString(), GlobalId = await idGen.GenerateIdentifierAsync<AddressCdc>().ConfigureAwait(false) }).ConfigureAwait(false);
}
/// <inheritdoc/>
public void RelinkIdentifierMappings(ValueIdentifierMappingCollection<string> coll)
{
coll.Invoke(GlobalId == default, () => GlobalId = coll.GetGlobalId(this, nameof(GlobalId)));
coll.Invoke(GlobalAlternateAddressId == default && AlternateAddressId != default, () => GlobalAlternateAddressId = coll.GetGlobalId(this, nameof(GlobalAlternateAddressId)));
}
}
/// <summary>
/// Represents the CDC model collection for the related (child) database table '[Legacy].[Address]'.
/// </summary>
public partial class AddressCdcCollection : List<AddressCdc> { }
#endregion
}