8 Replies
There are certain resources in my db that belong to our partners, for those resources, I always need to know the partner Id it belongs to. What is the best way to set up the PartnerId property on those model. I don’t want to have to eager, lazy load, or explicitly load it. I just want it to always be populated. Some tracked resources belong directly to partners like Users in the example, some belong to partners through relationships, the Tickets in the example.
The ones that only belong to partners through relationships, like tickets, is what’s causing me issues
I pretty much what a way to do this via an attribute, convention, or configuring the db context.
Just... do
Foreign keys are stored in the database
Always
They do not need to be loaded, lazily or eagerly
So what should my Ticket model look like?
Ah, wait, it goes through
User
Is this is situation where I should use MultiTenanting? Not very familiar with it
Well, since you should be
.Select()
ing your results into DTOs anyway, what's the harm in loading it then?I need to be able to handle them generically when a property is changed
On any entity that implements ITrackedResource
Using reflection
LazyLoading proxies with the commented out code is my best solution rn
This isn’t exactly what I do but imagine the following code.
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.