且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查LINQ中Field是否为空

更新时间:2023-01-20 23:37:55

你好ysrini;



试试这样 

 var tmpQry =来自dtOra中的recOra.AsEnumerable()
其中recOra.Field< int>(" ELAPSED_RUNTIME_SECS")!= null&& recOra.Field< int>(" ELAPSED_RUNTIME_SECS")> = 4
选择新的{nrecOra = recOra};


  


I am getting System.InvalidCastException

The original datatable can have null values but in my LINQ I want to exclude these from comparison

How to check for 'not null' in the WHERE clause?

var tmpQry = FROM recOra IN dtOra.AsEnumerable()
             WHERE  recOra.Field<int?>("ELAPSED_RUNTIME_SECS") >= 4
             SELECT NEW { nrecOra = recOra};

Thanks,

-srinivas y.

Hi ysrini;

Try it like this 

var tmpQry = from recOra in dtOra.AsEnumerable()
             where recOra.Field<int>("ELAPSED_RUNTIME_SECS") != null && recOra.Field<int>("ELAPSED_RUNTIME_SECS") >= 4
             select new { nrecOra = recOra};

  


相关阅读

技术问答最新文章