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


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.