我目前正在尝试在 linq 中进行嵌套查询,但收到一条错误消息:
var subcatquery = from categories in mydb.Categories
where categories.ParentId == null
select new
{
category = categories.Name,
subcat = (from sub in mydb.Categories
where sub.ParentId == sub.Id
select new
{
subcatItem = sub.Name,
subcatId = sub.Id
})
};
结果视图 =The type '<>f__AnonymousType0<subcatItem,subcatId>' exists in both 'myapplication.dll' and 'System.Web.dll'
我无法理解为什么..如果我删除子查询并将其放在自己的位置上...那就很好了。
subcat
类型是 a ,这collection<>
是问题所在吗?
class categoryGroup
{
public string category;
public Collection<subcategoryGroup> subcat;
}
class subcategoryGroup
{
public string subcatItem;
public int subcatId;
}