我有 foreach 来显示来自 myquery 的结果,当结果不为空时它可以工作。我想知道foreach还有其他吗?当 myquery 的结果为空时采取措施?
var rs = from cs in db.CsCustomers
from ai in db.ArInvoices
where cs.CustomerID == ai.CustomerID &&
ai.Kategori != null
orderby cs.Unit
select new
{
cs.CustomerID,
cs.Unit,
cs.Name
};
foreach (var r in rs)
{
c = new TableCell();
c.Text = r.CustomerID;
c.RowSpan = jk;
tr.Cells.Add(c);
c = new TableCell();
c.Text = r.Unit;
c.RowSpan = jk;
tr.Cells.Add(c);
c = new TableCell();
c.Text = r.Name;
c.RowSpan = jk;
tr.Cells.Add(c);
}