2

我目前正在使用

your = from p in (toSelect)
select new
{
  last = p.Last,
  current = p.CurrentPlayer,
  seats = from s in (p.Seated)
  select new
  {
      UID = s.UID,
      buyin = s.BuyIn
  }
}

p.Seated是一个数组,我怎么能通过null每次s.UID未设置?我知道“ where”,但我想知道哪些座位是免费的(例如null

希望这足够清楚。

4

2 回答 2

2

你可以试试这个:

your = from p in (toSelect)
select new
{
  last = p.Last,
  current = p.CurrentPlayer,
  seats = p.Seated.Select(s => s.UID != null
    ? new
      {
          UID = s.UID,
          buyin = s.BuyIn
      }
    : null;
}
于 2013-06-07T12:49:26.527 回答
0

将您分配给的表达式替换为seats

seats = p.Seated.Select(s => s != null ? new { UID = s.UID, buyin = s.BuyIn } : null)

希望这足够清楚。

我会诚实的。还不够清楚。是s.UID可以为空的类型,这就是我们需要比较的null吗?

于 2013-06-07T12:50:03.860 回答