EntityFramework 4已升级到5,无法使用lambda [英] EntityFramework 4 upgraded to 5, lambda is not available
问题描述
我已将 entityframework 4项目升级到5。我想在Include(我的动机是替换字符串定义)括号中使用lambda表达式。
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.
在我有这个妈妈:
context.WarrantyContract.Include("Car");
想要实现这一目标:
context.WarrantyContract.Include(w => w.Car);
但是当我尝试替换字符串时,Visual Studio无法识别我的意愿。
But when I try to replace string, visual studio is not eable to recognize my will.
我会感激任何正确的方向。
I'll appreciate any right direction.
推荐答案
系统中声明了http://msdn.microsoft.com/en-us/library/gg671236%28v=vs.103%29.aspx\">lambda版本的Include .Data.Entity.DbExtensions 类作为扩展方法
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);
这篇关于EntityFramework 4已升级到5,无法使用lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!