I have a problem that I could not find a solution, and I wonder if anyone can give advice.
I have a mocked datacontext / objectset made through interfaces and t4 templates, with some ninject magic, with the intention of having memory in the data sets for unit testing.
However, what should you do with foreign key values ββ/ navigation properties?
Suppose I have hotels and clients, ctx. Hotels have some values, but Customer.Hotels do not. It turns out something like this if this is a one-to-one relationship:
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Hotel>("HotelModel.FK_Customers_Hotels", "Hotel").Value;
and one-to-many:
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<BookingRow>("HotelModel.FK_BookingRows_Customers", "BookingRow");
The level of my skill is not enough to even understand what is happening here.
[edit:] Grand Master Julie Lerman confirms this is a dead end. You cannot correctly simulate object objects, for this you need POCOs.
source share