Linq 使用匿名类型在另一个列表中使用一个列表值

Linq 使用匿名类型在另一个列表中使用一个列表值,linq,list,Linq,List,我有一个匿名类型的列表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

我有一个匿名类型的列表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>'   

请展示一个简短但完整的程序来演示问题。目前我们不知道x变量是如何声明的。另外,请重新格式化您的代码,以避免在不必要时使用水平滚动。我认为他正在声明x。。。我为你准备了一点;顺便说一句:你有什么C手表执事之类的吗?基于你在这里重新分配x的假设,就像我在重新设计的问题中试图指出的那样,你应该很清楚为什么这不起作用!举个例子:第一类x有3个字段,第二类x有4个@CarstenKönig是的,我想这就是问题所在。谢谢,我从来没有尝试过,所以即使你有相同的结构,你也可能会遇到问题,我想说的是——所以重构它,并为此引入一个精简的结构/类。
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();