Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manage null with LINQ

Tags:

c#

linq

With this code

 var res = (from p in list where 
           p.FirstName.ToUpper() == firstName.ToUpper() || 
           p.LastName.ToUpper() == lastName.ToUpper() select p).ToList<Client>();

The p.FirstName, or the firstName can be NULL how can I manage this ?

Thanks,

like image 717
Kris-I Avatar asked Mar 17 '26 20:03

Kris-I


1 Answers

Like this:

where String.Equals(p.LastName, lastName, StringComparison.OrdinalIgnoreCase)
like image 157
SLaks Avatar answered Mar 19 '26 10:03

SLaks