var query = from t1 in Table1
join t2 in Table2
on new { t1.Id }
equals new { t2.Id}
select new
{
t1.Id,
t1.FirstName,
t1.MiddleName,//allows null values in the database
t1.LastName,
t1.phone //allows null values in the database
};
if(query.Count()>0)//fails here"The value for column MiddleName in table'Table1' is DBNULL"
{
}
有没有一种方法,我可以在我的LINQ查询中获取包含middleName和Phone的空值的所有行?LINQ查询失败的NULL值
“MiddleName”和“phone”的数据类型是什么? – used2could 2011-05-16 15:01:11
'Table1'和'Table2'是'DataTable'正确的,你没有使用Linq to SQL? – R0MANARMY 2011-05-16 15:01:37
你为什么加入T2?你永远不会使用它,你是否已经过滤了这个集合? – Nix 2011-05-16 15:03:18