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

在哪里...

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

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

在哪里...

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

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

在哪里...

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

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

在哪里...

Country = varchar(100)
4

3 回答 3

2

我将尝试对此进行尝试。基本上你要找的是一个投影。

TcCollection是你的数据集。

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
              });
于 2013-06-21T16:33:29.433 回答
1

您将不得不使用实体函数进行日期操作,例如 LINQ 中的 AddDays、AddMinutes。请看这个这个

于 2013-06-21T16:34:34.767 回答
0

Select中的一个case会在LINQ的projection中完成。你可以有一个多行匿名方法,这样你就可以有 if/else 语句,但这里我只使用三元运算符。

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

变成:

.Select(c=> new { countrySort = (c.country == "USA" ? 0 : 1)});
于 2013-06-21T16:25:17.200 回答