添加序列号字段时,表达式树可能不包含赋值运算符

时间:2019-05-24 07:02:54

标签: asp.net-core-2.1

我在linq查询中添加了序列号字段,但出现错误,看起来像“表达式树可能不包含赋值运算符”

int Index = 1;
var Result = from emp in db.EmpDetails 
join desc in db.tblDesignation on emp.D_Id equals desc.Id
join contry in db.tblCountry on emp.C_Id equals contry.Id
join propic in db.tblProfilePic on emp.Id equals propic.EmpId into propicgroup
from propicimage in propicgroup.DefaultIfEmpty()
orderby emp.Id descending
select new EmpDetails
{
     EmpIndex = Index++,
     Id = emp.Id,
     ProfilePic = propicimage.ImageName,
     UserName = emp.UserName,
     Gender = emp.Gender,
     DateOfBirth = emp.DateOfBirth,
     ContactNo = emp.ContactNo,
     Salary = emp.Salary,
     EmailId = emp.EmailId,
     Designation = desc.Designation,
     Country = contry.Country,
     DateOfJoin = emp.DateOfJoin
};

Error is on "Index++," please click this image link

错误看起来像“表达式树可能不包含赋值运算符”

0 个答案:

没有答案