http://msdn.microsoft.com/en-us/library/ee796239%28v=vs.91%29.aspx#Y3078
return this.ObjectContext.SalesOrderHeaders.OrderBy(e=>e.SalesOrderID);
所以,以下情况应该有效,
return this.ObjectContext.SERVERs.OrderBy(e=>e.username);
Visual Studio 2010表示没有“e”。
Error 13 Cannot convert lambda expression to type 'string' because it is not a delegate type D:\DOCUMENTSS\Visual Studio 2010\Projects\ExampleBusinessApplication\ExampleBusinessApplication.Web\DomainService1.cs 35 55 ExampleBusinessApplication.Web
Error 14 A local variable named 'e' cannot be declared in this scope because it would give a different meaning to 'e', which is already used in a 'parent or current' scope to denote something else D:\DOCUMENTSS\Visual Studio 2010\Projects\ExampleBusinessApplication\ExampleBusinessApplication.Web\DomainService1.cs 35 55 ExampleBusinessApplication.Web
答案 0 :(得分:1)
错误消息似乎告诉您e
已经被定义为包含return
语句的范围内其他位置的某些内容(可能是字符串)。没有看到你的代码,我只能猜测你有这样的东西:
method()
{
string e = "abcd";
return this.ObjectContext.SERVERs.OrderBy(e=>e.username);
}
这不会起作用,因为您尝试用作lambda表达式的参数的符号已经被声明为。
如果您不理解使用=>
语法来声明代理,那么您应该自己去理解。例如:) Here's a tutorial。