Linq check to see is there any NULLs in a set of DataRows? -
i have set datarows , want check if of fields in of rows has null value in it. came below, i'm not sure because i'm nesting all.
result.asenumerable().asqueryable().all(o => o.itemarray.all(i=>i == dbnull.value))
hard tell because can't put "watch" in lambdas.
actually need use any
(in code return true if values null) , asqueryable()
useless in case.
bool nullfound = result.asenumerable() .any(o => o.itemarray.any(i=>i == dbnull.value || == null));
then, if need list of rows value null, following:
var rowswithnulls = result.asenumerable() .where(o => o.itemarray.any(i=>i == dbnull.value || == null)) .tolist();
p.s.
i added null
check more safe, if sure have dbnull.value
, can remove it.
Comments
Post a Comment