2015-06-04 52 views
0

我想結合幾個表字段爲了產生一個組合的價值。結合幾個字段使用Linq

這裏是我的代碼:

from _showtime in db.tbl_Concert_Showtime join _concerthall in db.tbl_Concert_ConcertHall on _showtime.ConcertHallID equals _concerthall.ConcertHallID 
       join _hall in db.tbl_Concert_Hall on _concerthall.HallID equals _hall.HallID 
       join _hallfloor in db.tbl_Concert_Hall_Floor on _hall.HallID equals _hallfloor.HallID 
       join _place in db.tbl_Concert_Hall_Floor_Place on _hallfloor.FloorID equals _place.FloorID 
       where _place.PlaceID == id 
       select _showtime 

showtime表包括showIDstartdatestarttimeendtime領域。

如何在字段中選擇startdatestarttime

事情是這樣的:2015/12/12 12:25 -> 12:58

回答

3
from _showtime in db.tbl_blablabla  
select _showtime.startdate + " " + _showtime.starttime + " -> " + _showtime.enddate 

如果你想保持你原來欣欣對象,但只想補充一點,綜合價值,這樣做的follwoing:

from _showtime in db.tbl_blablabla  
select new 
{ 
    Showtime = _Showtime, 
    CombinedValue = _showtime.startdate + " " + _showtime.starttime + " -> " + _showtime.enddate 
} 
+0

如何選擇的名字新領域?像showID和NewSeveral字段 –

+0

這是什麼意思在這方面的名稱?結果將只是一個或多個字符串。 –

+0

我想在下拉列表中顯示結果。我需要showID字段值和NewSeveral(_showtime.startdate +「」+ _showtime.starttime +「 - >」+ _showtime.enddate)以供顯示 –