[英]Linq select multiple columns, condition not working
我想提取“連接和密封”條目,以防兩者都不是 null 或“”。 我的嘗試如下:
var fromElements = from el in l
where el.from != "" && el.from != null
select l.Select(i => new
{
i.Connection,
i.Seal
});
據我所知,問題在於每次匹配都會創建一個包含所有輸入的新 object。 有關如何解決此問題的任何提示?
如果 Connection 和 Seal 是 IEnumerable ' l ' 中的屬性元素
var fromElements = from el in l
where el.From != "" && el.From != null
select new
{
el.Connection,
el.Seal
}
據我了解,您想在 select 內制作 select ,這是不需要的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.