Posted By

housecor on 10/31/10


Tagged

operator null coalecing


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

voffcheg
Tyster


LINQ COALESCE to provide conditional when value is null in Anonymous type


 / Published in: C#
 

  1. var query = from m in db.TeamMembers
  2. orderby m.Name
  3. select new {
  4. Photo = m.Photo ?? "default.jpg",
  5. Modified = String.Format("{0:M/d/yyyy}", m.Modified),
  6. Created = String.Format("{0:M/d/yyyy}", m.Created)
  7. };

Report this snippet  

You need to login to post a comment.