bool
データ フィールドが(true/false) またはint
(1/0)の可能性がある DataTable で LINQ クエリを使用しています。LINQ クエリはメソッドの型を要求しField
、データ フィールドが異なる場合はInvalidCastException
がスローされます (キャッチできません)。
var query =
from tbl12 in t12.AsEnumerable()
where tbl12.Field<int>("theField") == 0
select new { T12 = tbl12 };
また
var query =
from tbl12 in t12.AsEnumerable()
where tbl12.Field<bool>("theField") == false
select new { T12 = tbl12 };
どうすればこれを回避できますか? フィールドが false または 0 の結果をフィルタリングしたい。