无法将 lambda 表达式转换为类型“字符串",因为它不是委托类型 [英] Cannot convert lambda expression to type 'string' because it is not a delegate type

查看:52
本文介绍了无法将 lambda 表达式转换为类型“字符串",因为它不是委托类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的 LINQ lambda 表达式:

I am using a LINQ lambda expression like so:

int Value = 1;
qryContent objContentLine;

using (Entities db = new Entities())
{
    objContentLine = (from q in db.qryContents
                      where q.LineID == Value
                      orderby q.RowID descending
                      select q).FirstOrDefault();
}

但是,我收到以下错误:

However, I am getting the following error:

无法将 lambda 表达式转换为类型字符串",因为它不是委托类型

Cannot convert lambda expression to type 'string' because it is not a delegate type

推荐答案

我认为你在这个系统类中缺少using System.Linq;.

I think you are missing using System.Linq; from this system class.

并在代码中添加using System.Data.Entity;

这篇关于无法将 lambda 表达式转换为类型“字符串",因为它不是委托类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆