@@ -129,15 +129,39 @@ public virtual DbContext Context
129
129
public virtual IEntityType Metadata
130
130
=> InternalEntry . EntityType ;
131
131
132
+ /// <summary>
133
+ /// Provides access to change tracking information and operations for a given property or navigation of this entity.
134
+ /// </summary>
135
+ /// <remarks>
136
+ /// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see> for more information and
137
+ /// examples.
138
+ /// </remarks>
139
+ /// <param name="propertyBase">The property or navigation to access information and operations for.</param>
140
+ /// <returns>An object that exposes change tracking information and operations for the given property.</returns>
141
+ public virtual MemberEntry Member ( IPropertyBase propertyBase )
142
+ {
143
+ Check . NotNull ( propertyBase , nameof ( propertyBase ) ) ;
144
+
145
+ return propertyBase switch
146
+ {
147
+ IProperty property => new PropertyEntry ( InternalEntry , property ) ,
148
+ INavigationBase navigation => navigation . IsCollection
149
+ ? new CollectionEntry ( InternalEntry , navigation )
150
+ : new ReferenceEntry ( InternalEntry , ( INavigation ) navigation ) ,
151
+ _ => throw new InvalidOperationException (
152
+ CoreStrings . PropertyNotFound ( propertyBase . Name , InternalEntry . EntityType . DisplayName ( ) ) )
153
+ } ;
154
+ }
155
+
132
156
/// <summary>
133
157
/// Provides access to change tracking information and operations for a given
134
- /// property or navigation property of this entity.
158
+ /// property or navigation of this entity.
135
159
/// </summary>
136
160
/// <remarks>
137
161
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see> for more information and
138
162
/// examples.
139
163
/// </remarks>
140
- /// <param name="propertyName">The property to access information and operations for.</param>
164
+ /// <param name="propertyName">The property or navigation to access information and operations for.</param>
141
165
/// <returns>An object that exposes change tracking information and operations for the given property.</returns>
142
166
public virtual MemberEntry Member ( string propertyName )
143
167
{
@@ -163,9 +187,8 @@ public virtual MemberEntry Member(string propertyName)
163
187
}
164
188
165
189
/// <summary>
166
- /// Provides access to change tracking information and operations for all
167
- /// properties and navigation properties of this entity.
168
- /// </summary>
190
+ /// Provides access to change tracking information and operations for all properties and navigations of this entity.
191
+ /// </summary>-
169
192
/// <remarks>
170
193
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see> for more information and
171
194
/// examples.
@@ -174,15 +197,33 @@ public virtual IEnumerable<MemberEntry> Members
174
197
=> Properties . Cast < MemberEntry > ( ) . Concat ( Navigations ) ;
175
198
176
199
/// <summary>
177
- /// Provides access to change tracking information and operations for a given
178
- /// navigation property of this entity.
200
+ /// Provides access to change tracking information and operations for a given navigation of this entity.
179
201
/// </summary>
180
202
/// <remarks>
181
203
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
182
204
/// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
183
205
/// for more information and examples.
184
206
/// </remarks>
185
- /// <param name="propertyName">The property to access information and operations for.</param>
207
+ /// <param name="navigationBase">The navigation to access information and operations for.</param>
208
+ /// <returns>An object that exposes change tracking information and operations for the given property.</returns>
209
+ public virtual NavigationEntry Navigation ( INavigationBase navigationBase )
210
+ {
211
+ Check . NotNull ( navigationBase , nameof ( navigationBase ) ) ;
212
+
213
+ return navigationBase . IsCollection
214
+ ? new CollectionEntry ( InternalEntry , navigationBase )
215
+ : new ReferenceEntry ( InternalEntry , ( INavigation ) navigationBase ) ;
216
+ }
217
+
218
+ /// <summary>
219
+ /// Provides access to change tracking information and operations for a given navigation of this entity.
220
+ /// </summary>
221
+ /// <remarks>
222
+ /// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
223
+ /// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
224
+ /// for more information and examples.
225
+ /// </remarks>
226
+ /// <param name="propertyName">The navigation to access information and operations for.</param>
186
227
/// <returns>An object that exposes change tracking information and operations for the given property.</returns>
187
228
public virtual NavigationEntry Navigation ( string propertyName )
188
229
{
@@ -234,8 +275,23 @@ public virtual IEnumerable<NavigationEntry> Navigations
234
275
}
235
276
236
277
/// <summary>
237
- /// Provides access to change tracking information and operations for a given
238
- /// property of this entity.
278
+ /// Provides access to change tracking information and operations for a given property of this entity.
279
+ /// </summary>
280
+ /// <remarks>
281
+ /// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see> for more information and
282
+ /// examples.
283
+ /// </remarks>
284
+ /// <param name="property">The property to access information and operations for.</param>
285
+ /// <returns>An object that exposes change tracking information and operations for the given property.</returns>
286
+ public virtual PropertyEntry Property ( IProperty property )
287
+ {
288
+ Check . NotNull ( property , nameof ( property ) ) ;
289
+
290
+ return new PropertyEntry ( InternalEntry , property ) ;
291
+ }
292
+
293
+ /// <summary>
294
+ /// Provides access to change tracking information and operations for a given property of this entity.
239
295
/// </summary>
240
296
/// <remarks>
241
297
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see> for more information and
@@ -263,17 +319,36 @@ public virtual IEnumerable<PropertyEntry> Properties
263
319
264
320
/// <summary>
265
321
/// Provides access to change tracking and loading information for a reference (i.e. non-collection)
266
- /// navigation property that associates this entity to another entity.
322
+ /// navigation that associates this entity to another entity.
267
323
/// </summary>
268
324
/// <remarks>
269
325
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
270
326
/// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
271
327
/// for more information and examples.
272
328
/// </remarks>
273
- /// <param name="propertyName ">The name of the navigation property .</param>
329
+ /// <param name="navigation ">The reference navigation.</param>
274
330
/// <returns>
275
- /// An object that exposes change tracking information and operations for the
276
- /// given navigation property.
331
+ /// An object that exposes change tracking information and operations for the given navigation.
332
+ /// </returns>
333
+ public virtual ReferenceEntry Reference ( INavigationBase navigation )
334
+ {
335
+ Check . NotNull ( navigation , nameof ( navigation ) ) ;
336
+
337
+ return new ReferenceEntry ( InternalEntry , ( INavigation ) navigation ) ;
338
+ }
339
+
340
+ /// <summary>
341
+ /// Provides access to change tracking and loading information for a reference (i.e. non-collection)
342
+ /// navigation that associates this entity to another entity.
343
+ /// </summary>
344
+ /// <remarks>
345
+ /// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
346
+ /// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
347
+ /// for more information and examples.
348
+ /// </remarks>
349
+ /// <param name="propertyName">The name of the navigation.</param>
350
+ /// <returns>
351
+ /// An object that exposes change tracking information and operations for the given navigation.
277
352
/// </returns>
278
353
public virtual ReferenceEntry Reference ( string propertyName )
279
354
{
@@ -297,17 +372,37 @@ public virtual IEnumerable<ReferenceEntry> References
297
372
298
373
/// <summary>
299
374
/// Provides access to change tracking and loading information for a collection
300
- /// navigation property that associates this entity to a collection of another entities.
375
+ /// navigation that associates this entity to a collection of another entities.
376
+ /// </summary>
377
+ /// <remarks>
378
+ /// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
379
+ /// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
380
+ /// for more information and examples.
381
+ /// </remarks>
382
+ /// <param name="navigation">The collection navigation.</param>
383
+ /// <returns>
384
+ /// An object that exposes change tracking information and operations for the given navigation.
385
+ /// </returns>
386
+ public virtual CollectionEntry Collection ( INavigationBase navigation )
387
+ {
388
+ Check . NotNull ( navigation , nameof ( navigation ) ) ;
389
+
390
+ return new CollectionEntry ( InternalEntry , navigation ) ;
391
+ }
392
+
393
+ /// <summary>
394
+ /// Provides access to change tracking and loading information for a collection
395
+ /// navigation that associates this entity to a collection of another entities.
301
396
/// </summary>
302
397
/// <remarks>
303
398
/// See <see href="https://aka.ms/efcore-docs-entity-entries">Accessing tracked entities in EF Core</see>
304
399
/// and <see href="https://aka.ms/efcore-docs-changing-relationships">Changing foreign keys and navigations</see>
305
400
/// for more information and examples.
306
401
/// </remarks>
307
- /// <param name="propertyName">The name of the navigation property .</param>
402
+ /// <param name="propertyName">The name of the navigation.</param>
308
403
/// <returns>
309
404
/// An object that exposes change tracking information and operations for the
310
- /// given navigation property .
405
+ /// given navigation.
311
406
/// </returns>
312
407
public virtual CollectionEntry Collection ( string propertyName )
313
408
{
0 commit comments