我的应用程序中有一个类
public class ProductInfo
{
public int ProductId {get;set;}
public int ProductType{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我想编写一个linq查询,它可以以逗号分隔格式返回ProductIds列表,其中ProductType等于某个数字?
我尝试在我的Linq语句中使用string.join,但它似乎不起作用.
Kin*_*ing 191
var s = string.Join(",", products.Where(p => p.ProductType == someType)
.Select(p => p.ProductId.ToString()));
Run Code Online (Sandbox Code Playgroud)