11

I have upgraded my "entityframework 4" project to 5. I want to use lambda expression in Include (my motivation is to suplant string definitions) brackets.

At this momemnt I have:

context.WarrantyContract.Include("Car");

And want to achieve this one:

context.WarrantyContract.Include(w => w.Car);

But when I try to replace string, visual studio is not eable to recognize my will.

I'll appreciate any right direction.

Martin Majoroš
  • 409
  • 1
  • 6
  • 17

1 Answers1

22

The lambda version of the Include is declared in the System.Data.Entity.DbExtensions class as an extension method.

In order to use it you need to add an using with the right namespace in your file the:

using System.Data.Entity;

//...

context.WarrantyContract.Include(w => w.Car);
nemesv
  • 138,284
  • 16
  • 416
  • 359