我有一个带有匿名类型的列表x,其中我想使用预先计算的值
int count1 =
(from users in dc.BeadSets
where users.UserId == i
select users
).Count();
var x =
(from users in dc.Users
where users.Id == i
select new { username = users.UserName
, fullname = users.FirstName + " " + users.LastName
, userid = users.Id
}
).ToList();
现在这样可以正常工作
Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>'
to 'System.Collections.Generic.List<AnonymousType#2>'
但是当我试图像这样使用时抛出错误
int count1 =
(from users in dc.BeadSets
where users.UserId == i
select users
).Count();
x =
(from users in dc.Users
where users.Id == i
select new { beadsets= count1
, username = users.UserName
, fullname = users.FirstName + " " + users.LastName
, userid = users.Id }
).ToList();