.net - c# linq how to check for null values in the same column that i need to be not null -


i have query in linq

var finalresults = (from r in results.asenumerable()                    datetime.now.subtract(r.field<datetime>("senton")).minutes > 7                    select r                    ).tolist(); 

sometimes senton column null , want ignore these cases. how can remove these null cases ?

if required can staging (another) table has not null values , can continue

the table results can have table, lets results2 doesn't have null values or senton ?

if field senton can null, have return datetime? instead of datetime.

try:

var finalresults = (from r in results.asenumerable()                    r.field<datetime?>("senton") != null &&                          datetime.now.subtract(r.field<datetime>("senton")).minutes > 7                    select r                    ).tolist(); 

alternatively, pointed out in comment, can use datarow.isnull.

var finalresults = (from r in results.asenumerable()                    !r.isnull("senton") &&                          datetime.now.subtract(r.field<datetime>("senton")).minutes > 7                    select r                    ).tolist(); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -