1
Dateadd(minute, TS.duration, TS.datesched) 

WHERE...

TS.Duration = int.
TS.datesched = datetime.

RTRIM(ISNULL(TC.CityLocation, '') + ' ' + ISNULL(TC.StateLocation, '')

WHERE...

TC.CityLocation = varchar(50)
TC.StateLocation = varchar(10)

CASE
WHEN country = market 
OR country = 'USA' THEN market 
ELSE country + ' | ' + market 
END AS BroadcastMarket

WHERE...

Country = varchar(100)
Market = varchar(100)

CASE 
WHEN country = 'USA' THEN 0 
ELSE 1 
END AS CountrySort

WHERE...

Country = varchar(100)
arunlalam
  • 1,838
  • 2
  • 15
  • 23
JJ.
  • 9,580
  • 37
  • 116
  • 189

3 Answers3

2

I'm going to try an take a stab at this. Basically what your looking for is a projection.

TcCollection is your data set.

var result = (from i in TcCollection
              select new 
              {
                  Date = EntityFunctions.AddMinutes(i.datesched, i.duration),
                  Location = (i.CityLocation ?? "") + " " + (i.StateLocation ?? ""),
                  BroadcastMarket = 
                      (i.market == i.country || i.country == "USA") ? 
                      i.market : 
                      i.country + " | " + i.market,
                  CountrySort = (i.country == "USA") ? 0 : 1
              });
Jay
  • 6,224
  • 4
  • 20
  • 23
1

You will have to use Entity Functions for date operations like AddDays,AddMinutes in LINQ. Please see this and this

Community
  • 1
  • 1
Sandeep Pote
  • 161
  • 8
0

A case in the Select will be done in the projection of the LINQ. You could have a multiline anonymous method so that you could have if/else statements instead, but here I show just using a ternary operator.

CASE 
WHEN country = 'USA' THEN 0 
ELSE 1 
END AS CountrySort

Becomes:

.Select(c=> new { countrySort = (c.country == "USA" ? 0 : 1)});
AaronLS
  • 37,329
  • 20
  • 143
  • 202