C
C#17mo ago
KaLu

❔ A quick question

In this code i initialize a object. UpdatedByUser = request.User.VacationApprovalManager, UpdatedByUserId = request.User.VacationApprovalManager.Id, I just want to know, do I need to use the first line of code or is the adding of the Id of the VacationApprovalManager enough for EntityFramework to figure out the updated user? basically do i need the first line of code ( UpdatedByUser = request.User.VacationApprovalManager)?
4 Replies
Anu6is
Anu6is17mo ago
1. the id should be enough 2. couldn't you just test this? also, it not really for EF to figure out the updated user.. when you store the id here, it's up to you to include the full user details (navigation property) when retrieving the history record if necessary
KaLu
KaLuOP17mo ago
Yea yea i have to include it everytime use the DbContext to get the history record
Angius
Angius17mo ago
If you set the Foo navigation property you don't need to set FooId foreign key, and vice versa Just one of them is enough Assuming, of course, everytihing is set up properly
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server