リストの列から Null 許容値を選択するにはどうすればよいですか。
たとえば、クライアント ID (nullable 列) に値を渡す代わりに、以下のようなリストに変換されたデータセットがあるとします。null を渡す必要があります。私は自分で次の試みをしました:
var reqlist = (from list in tableList.AsEnumerable()
where (list.Field<int?>("ClientID") == clientID)
&& list.Field<bool>("VisibleToAdmin") == true
&& list.Field<bool>("Required") == true
select list.Field<string>("FieldName"));
1.
var reqlist = (from list in tableList.AsEnumerable()
where (list.Field<int?>("ClientID") == null)
&& list.Field<bool>("VisibleToAdmin") == true
&& list.Field<bool>("Required") == true
select list.Field<string>("FieldName"));
2.
var reqlist = (from list in tableList.AsEnumerable()
where (list.Field<int?>("ClientID") == (int?)(null))
&& list.Field<bool>("VisibleToAdmin") == true
&& list.Field<bool>("Required") == true
select list.Field<string>("FieldName"));
3.
var reqlist = (from list in tableList.AsEnumerable()
where (list.Field<int?>("ClientID") == (bool?)(null))
&& list.Field<bool>("VisibleToAdmin") == true
&& list.Field<bool>("Required") == true
select list.Field<string>("FieldName"));
4.
var reqlist = (from list in tableList.AsEnumerable()
where (list.IsNull("ClientID"))
&& list.Field<bool>("VisibleToAdmin") == true
&& list.Field<bool>("Required") == true
select list.Field<string>("FieldName"));
上記のすべてのメソッドで、 anInvalidCastException
がスローされます。