日期:2014-05-20  浏览次数:20832 次

LINQ的Concat连接集合中包含NULL
var q = (
  from c in db.Customers
  select c.Phone
  ).Concat(
  from c in db.Customers
  select c.Fax //Fax中包含null
  )

GridView1.DataSource = q;
GridView1.DataBind();

绑定时提示错误:在容器中未找到数据项。容器必须实现 IDataItemContainer 或者具有名为 DataItem 的属性。
加入where T1.Fax != null 剔除Null后,能够正常绑定GridView。

请教下这个是什么问题???????

------解决方案--------------------
var q = (
from c in db.Customers
select new{Phone=c.Phone}
).Concat(
from c in db.Customers
select new{Phone=c.Fax}
)

两个集合内的字段要统一吧