LINQ Handle null in query

By [)ia6l0 iii

You can use ternary operator to handle null values in LINQ query. See the following example.


var user = from
project in Projects
select new {
  
name=project.Name,
   teamsize = project.teamsize,
   manager = (project.manager== null) ? "No Manager assigned yet" : project.manager };

Related FAQs

Use the link attribute to link a style sheet to your web page
Use the ToCharArray with the Linq Reverse method.
var data = Enumerable.Range(100,10).ToArray();
The LinQ SKIP operator lets you skip the results you want, and take the rest. See below for an code sample.
The LinQ Take operator lets you take only the results you want. See below for an code sample.
We can use LINQ to initialize elements of an array with a specified range of values. The following statement initializes an interger array with values of 20-29.
LINQ Handle null in query  (1221 Views)