Converting Legacy App to .Net 8
Hi, we've got a legacy app in .Net 4.6 Framework.
it currently uses MSharp (which is not that known) framework, and I have been converting it to .Net 8 using clean-architecture as best as I can so far.
One thing that bothers me is loading entity navigation data (with EF 8).
The way the project is currenctly set up, as a simplified example is:
StaffMembers table,
WeekShifts table - contains weekStart date, shift1 - shift7 IDs.
Contracts table - contract data, staffMemberId, rotationId
Rotations table - has data regarding a weekly pattern for setting default shifts if none set manually.
- current legacy backend setup:
StaffMember class contains all DB columns as fields/properties.
it also contains multiple methods such as:
GetShift(Datetime date)
this method basically checks
1. the WeekShifts table to find the shift,
2. If none found, get latest contract, set and return the default shift based on contract's rotation.
The issue:
Now what if I want to get all staff who have a shift on a particular date, I'd have to load all those staffs' WeekShifts navigation property, the contracts, and each contract's (or latest) rotation data.
This method is used A LOT. if i keep it in StaffMember class, I'll have to find a way to always load that related data otherwise the methid would return null, if no WeekShifts or contract is loaded for example.
loading that data everytime before I make a .GetShift() call doesn't seem like a good solution to me since it gets messy.
Having a separate service for StaffMemberService.GetShift() method that loads all neccessary data doesn't seem that good of an idea if I have to load multiple staff.
(I'd have to create overload methods in case I need more than 1 staff so that I dont make a DB call for each staff).
what about other methods that also call staffMember's GetShift method
7 Replies
Unknown User•4d ago
Message Not Public
Sign In & Join Server To View
yes it is a Web app, and you're right, it is not neccessarily a "conversion" I'm doing but a complete rewrite
Unknown User•4d ago
Message Not Public
Sign In & Join Server To View
I get what you are saying, thats correct that I've been using generic repos on top of EF Core also
so in the specific case of using a GetShift method for a staff member, how would you go about it?
not sure if keeping it in the partial class of StaffMember entity makes sense.
obviously I need to load related data so that it returns the correct value
I'm just not sure how to structure all this, knowing that I need to use such methods multiple times, that need navigation data loaded ahead of running them
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
makes sense, I guess it is mainly CA that's been confusing me since I feel like it caused a bit more "workarounds" than it helped
thanks for taking the time 🙏
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View