1

My question looks simple to me but not getting it fixed. I am using EF 6 and LINQ to SQL in Visual Studio 2013. I want to fetch a record from second table on behalf of foreign key being used in first table. I wanted to use 'Include' function but 'Include' function neither show table names in IntelliSense nor accepts in a lambda expression like this:

var record= db.tblChild.Include(x=>x.tblParent)

My original code shows the libraries added.

enter image description here

3
  • You're missing a semicolon after the problematic line. What is the error? Hover over the lambda expression and tell us what the tooltip says. Commented Dec 8, 2015 at 19:48
  • 1
    using System.Data.Entity; is what you need to be able to reference the lamda version of .Include, so that should work. We need to see what the error it is giving you after you add the semi-colon. Commented Dec 8, 2015 at 19:51
  • My error is fixed. Actually I wasn't generating SubSource Property in ShipmentCharges Class. Generating that fixed the Issue. :) Commented Dec 8, 2015 at 19:52

2 Answers 2

5

In order to use lambdas in Include you have to import the System.Data.Entity namespace (which you have) and also reference EntityFramework.dll which includes the necessary extension methods.

Sign up to request clarification or add additional context in comments.

2 Comments

My error is fixed. Actually I wasn't generating SubSource Property in ShipmentCharges Class. Generating that fixed the Issue. :)
@IkramKhan Well, posting the error would have put us on the right path way faster. Either way, good to hear you've solved it.
-1

You only need to add:

using System.Data.Entity;

Into your Namespace.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.