Ikram Khan
Ikram Khan

Reputation: 89

LINQ, Use Lambda Expression in Include Function

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

Upvotes: 1

Views: 3721

Answers (2)

Frank Pena
Frank Pena

Reputation: 111

You only need to add:

using System.Data.Entity;

Into your Namespace.

Upvotes: -1

Mihai Caracostea
Mihai Caracostea

Reputation: 8466

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.

Upvotes: 5

Related Questions