Generating a Case Statement in LINQ to SQL

February 12, 2008 14:07 by admin

Denny.NET has a post describing how to generate a SQL case statement in LINQ to SQL.  His example is:

var gimmeh_gimmeh =
from t in db.sc_Timeslots
where (t.starttime.Minute % 5 == 0) || (t.starttime.Minute % 10 == 0)
select new
{
  t.id,
  t.starttime,
  interval = (t.starttime.Minute % 5 == 0) ? "5 Minutes" : "10 Minutes"
};


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 6. 2009 16:59