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

Deep Sharma picture Deep Sharma · Oct 5, 2013 · Viewed 134.1k times · Source

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

Answer

S. S. Rawat picture S. S. Rawat · Oct 5, 2013

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

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