EntityFramework 4 upgraded to 5, lambda is not available

天大地大妈咪最大 提交于 2019-11-30 02:44:55

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/14518149/entityframework-4-upgraded-to-5-lambda-is-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!