Reputation: 2674
I'm having trouble with entity framework 4.1 and relationships.
Here are my classes:
[Table("PROJTABLE")]
public class Certifikat {
[Key]
public long Recid { get; set; }
public String Projid { get; set; }
public virtual StandardAndScope StandardInfo { get; set; }
}
[Table("DS_CRT_PROJSTANDARDSCOPE")]
public class StandardAndScope {
//[Key]
//public long RECID { get; set; }
[Key]
public String Projid { get; set; }
public String Standard { get; set; }
public String Scope { get; set; }
}
Since I have no control over the databases, I can't change the keys and id's to support the conventions, and I'm stuck with this setup.
My problem is, Certifikat CAN have a relationship with one StandardAndScope. The key in both tables are called Projid - but this isn't strictly the primary key in the database for either tables.
All I really want is to say: "certifikat c join standardandscope s on c.Projid=s.Projid"
How do I accomplish this with fluent api?
Upvotes: 0
Views: 116
Reputation: 9566
I think you are looking for something like this:
var result = dataContext.Certifikats
.Join(dataContext.StandardAndScopes,
c => c.Projid,
s => s.Projid,
(c, s) => new
{
Certifikat = c,
StandardAndScope = s
});
Where dataContext
is an instance of your DbContext
class.
Upvotes: 1