Giving the following tables.
Project
Id: int not null PK
Type: nvarchar(10) not null
SomeProperty: nvarchar(50)
ChangeRequest
Id: int not null PK
Type: nvarchar(10) not nul
SomeProperty: nvarchar(50)
Approval
Id: int not null PK
RowId: int not null
RowType: nvarchar(10) not null
SomeProperty: nvarchar(50)
I want to have associations like this:
- Project(Id, Type) -> Approval(RowId, RowType)
- ChangeRequest(Id, Type) -> Approval(RowId, RowType)
In a way that if I was selecting the data from database I would do something like:
select p*, a.*
from Project p
left join Approval a on a.RowId = p.Id and a.RowType = p.Type
Project and ChangeRequest are entities completely different (I just put the simplified model), but both may have 0..N Approvals.
Is it possible to map such relations using Entity Framework?