Query data using LINQ to SQL and Entity Framework with foreign key? (Help me please)

Posted by The Wind on Stack Overflow See other posts from Stack Overflow or by The Wind
Published on 2010-05-28T03:39:10Z Indexed on 2010/05/28 3:41 UTC
Read the original article Hit count: 355

Hello!

There is a problem I need help with your query on the data using LINQ to SQL and Entity Framework (I'm using Visual Studio 2010).

My picure here: http://img.tamtay.vn/files/photo2/2010/5/28/10/962/4bff3a3b_1093f58f_untitled-1.gif

I have three tables:

  1. tbl NewsDetails

  2. tblNewsCategories

  3. tblNewsInCategories

(See screen 1 in my picture)

Now, I want to retrieve records in the tblNewsDetails table, with condition: CategoryId=1, as the following results:

(See screen 2 in my picture)

But NewsID and CategoryId in tblNewsInCategories table is two foreign key, I do not see them and I do not know how to use them in your code.

My code has errors:

(See screen 3 in my picture)

Please help me. Thanks!

(I am a new member, should not have the right to insert images)

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about linq-to-sql