我正在使用LINQ在两个数据表之间执行右连接。在orderby语句处出现了错误“指定的强制转换无效”。
数据库中“SomeOtherID”列的类型为System.Int64,允许DBNull。该列在数据中有一些空值,这是有效的。似乎这些空值必须以某种方式在orderby语句中处理,但我不确定如何处理。数据通过Web服务传输。我检查了reference.cs文件,该列的相应属性为int。
LINQ语句应该怎么写呢?
数据库中“SomeOtherID”列的类型为System.Int64,允许DBNull。该列在数据中有一些空值,这是有效的。似乎这些空值必须以某种方式在orderby语句中处理,但我不确定如何处理。数据通过Web服务传输。我检查了reference.cs文件,该列的相应属性为int。
LINQ语句应该怎么写呢?
var query = (from table1 in DataTable1.AsEnumerable()
join table2 in DataTable2.AsEnumerable()
on (int) table1["CustomerID"] equals (int) table2["CustomerID"] into outer
from table2 in outer.DefaultIfEmpty()
orderby (int?)table2["SomeOtherID"]
select new
{
......
});