Here is an interresting question, we have 2 classes (note that these are just nonsense to clarify my problem)
class Foo
{
public int Id { get; set; }
}
class Bar
{
public int Id { get; set;}
public int FooId { get;set;}
}
Now using Code First in EF 4.1, i want the following: Foo has 0 or more Bars with cascade delete enabled. This is easily doable by making actual properties in the models (A collection of Bar in foo) but the models are also DTO's and therefore cant carry on extra properties on them (e.g. if you want all the Bar's for a given Foo, you need to ask the Service in a specific query).
Is there any way to accomplish this? Currently i have a replica of Foo and Bar special for the EF where my repository translates between the replica and the actual DTO.
I'm hoping there are better ways, if so, please teach me.
Thanks!