How to make Entity Key Mapping in Entity Framework like sql's foreign key?

Posted by programmerist on Stack Overflow See other posts from Stack Overflow or by programmerist
Published on 2010-04-07T07:35:36Z Indexed on 2010/04/14 15:43 UTC
Read the original article Hit count: 242

I try to give entity map on my entity app. But how can I do it? I try to make it like below:

var test = ( from k in Kartlar where k.Rehber.....

above codes k.(can not see Rehber or not working ) if you are correct , i can write k.Rehber.ID and others. i can not write:

from
 k in
 Kartlar
where
k.Rehber.ID = 123 //assuming that navigation property name is Rehbar and its primary key of Rehbar table is ID
&& k.Kampanya.ID = 345 //assuming that navigation property name is Kampanya and its primary             //key of Kampanya table is ID
&& k.Birim.ID = 567 //assuming that navigation property name is Birim and its primary key of Birim table is ID
select
k

images you can see: alt text

also: You should look : http://i42.tinypic.com/2nqyyc6.png

I have a table it includes 3 foreign key field like that:

My Table: Kartlar

  • ID (Pkey)
  • RehberID (Fkey)
  • KampanyaID (Fkey)
  • BrimID (Fkey)
  • Name
  • Detail

How can i write entity query with LINQ ?

select * from Kartlar where RehberID=123 and KampanyaID=345 and BrimID=567

BUT please be careful I can not see RehberID, KampanyaID, BrimID in entity they are foreign key. I should use entity key but how?

© Stack Overflow or respective owner

Related posts about c#3.0

Related posts about ASP.NET