开发者

Linq Lambda Expression

开发者 https://www.devze.com 2022-12-14 09:55 出处:网络
I am trying to do this on a method which is basically a mapper - maps old categories List to a new List. The OldCategory has fewer properties.

I am trying to do this on a method which is basically a mapper - maps old categories List to a new List. The OldCategory has fewer properties.

return categories = from c in oldCategories select new Category 
{  
   CategoryName = c.CategoryName, 
   Id = c.CategoryId, 
   Teams = CombineTeam(c.Team, coreTeam)
};

Why can't I use CombineTeam method in the expression? Help appreciated. Thanks

UPDATE: Not working because c.Team is IQueryable and CombineTeam methods takes a List

Can a开发者_运维问答nyone help me convert IQueryable to List within the expression?


return categories = from c in oldCategories select new Category 
{  
CategoryName = c.CategoryName, 
Id = c.CategoryId, 
Teams = CombineTeam(c.Team.ToList(), coreTeam)
};
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号