I'm not entirely sure I understand, I'm afraid to say.
I'm *assuming* that you are indicating that I should fetch the related
entity (from where?) if I have the ID, otherwise create a new entity.
I'm assuming you mean
var r = Get<Region>(regionId) ?? new Region();
2 things.
One, where does that code go? If it's inside the Territory entity (in
the Region property) then that means that the entity needs to know
about the repository (effectively). Otherwise, it'd be in the service/
client code:
Territory territory = new Territory("Some Territory",
RegionRepository.Get(regionId) ?? new Region();
TerritoryRepository.SaveOrUpdate(territory);
Which leads me to point 2: I'm trying to avoid a prefetch of the
Region, since I know the region ID and I don't need to touch the
Region table, only the Territory table, so the prefetch is a bit/
completely unnecessary and expensive.
Thanks.
On Apr 25, 5:12 pm, "Ayende Rahien" <
aye...@ayende.com> wrote:
> var t = Get<Territory>(territoryId) ?? new Territory();
>
> On Fri, Apr 25, 2008 at 7:00 PM,
johnny.recip...@gmail.com <