How can I select the Nullable Value from a column from the list.
Say for example I have a dataset converted into a list like below instead of passing a value in the client id(nullable column). I need to pass null. I've made the following attempts myself:
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"));
With all of the above methods, an InvalidCastException
is thrown.