This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I currently have a setup similar to this: Employer - OverTimePercentages - RegisteredHours Where: So the one to one relation between employer and overtimepercentages is more like a one to many. However, I'm only interested in the currently active overtimepercentage. I don't want to say something like: employer.OverTimePercentages.Max(x => x.Id); kind regards, |
|
|
You should be able to avoid record deletion by making the one-to-one association nullable. However, I'd be inclined to suggest a different design, in which the relation between Employer and OvertimePercentage is indeed a one-to-many, but the Employer has an additional ActiveOvertimePercentageId field. You can then write something like: partial class Employer { The idea is that you retain the association of overtime percentages, even inactive ones, to employers, and merely switch which one the employer is using at the moment. The nullable one-to-one association leaves you with 'orphaned' overtime percentages which are referenced by RegisteredHours entities but are no longer associated with an employer, which feels a bit uncomfortable. Obviously, the correct design depends on your business domain model, which you know better than I do -- just offering this as a suggestion. |
|