Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

LINQ : contains not checking with null values.

$
0
0

Hi,

I want to check some word which contains some + symbols. when i write the below query it should return true.

but, i am getting object reference error.

Also my condition is should check null value in column2 and column3

below is my code:


Inparam1 = "A+B";  
bool Result1 = DT1.AsEnumerable()
                               .Any(row => (row.Field<String>("Col1").contains(Inparam1)) && (row.Field<String>("col2") == null) && (row.Field<String>("col3") == null)));

The above code should return "TRUE" as per my below referring table. But, it returns "Object reference Error"

DT1 Table

Col1Col2Col3
A+B/D+EB  
A/D+EB  
A+B/X+A1  
A23

what is the problem and where i want to change the code..?


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>