无法转换拉姆达前pression键入“字符串',因为它不是委托类型 [英] Cannot convert lambda expression to type 'string' because it is not a delegate type

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

问题描述

我使用LINQ拉姆达前pression像这样:

  int值= 1;
qryContent objContentLine;使用(实体DB =新的实体())
{
    objContentLine =(从db.qryContents q
                      其中,q.LineID ==价值
                      排序依据q.RowID降
                      选择Q).FirstOrDefault();
}

不过,我收到以下错误:


  

无法转换拉姆达前pression键入字符串',因为它不是一个委托类型



解决方案

我认为你正在使用System.Linq的缺失; 此系统类

,并添加 System.Data.Entity的; 到code

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:

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

解决方案

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

and also add System.Data.Entity; to the code

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

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