linq多表查询2

 var List = from tt in DB.T_DmcDataTravelTime

                       select new
                       {
                           tt.TravelTimeID,
                           tt.TravelTimeTypeName,
                           tt.TravelTimeTypeID,
                           tt.TravelTime,

                           AirportName = (tt.TravelTimeTypeID == (int)eDmc.Common.TraveltimeType.Between_Supplier_and_Supplier) ?
                          (from sp in DB.T_DmcDataSupplier
                           join ct in DB.T_DmcDataCity on sp.CityID equals ct.CityID
                           where sp.SupplierID == tt.VenueOneID
                           select new
                           {
                               TextField = ct.CityName + "," + sp.SupplierName
                           }).FirstOrDefault().TextField : (from a in DB.T_DmcDataAirport
                                                            join at in DB.T_DmcDataAirportTerminal on a.AirportID equals at.AirportID
                                                            where a.AirportID == tt.VenueOneID
                                                            select new
                                                            {
                                                                TextField = a.AirportName + "," + at.TerminalName
                                                            }).FirstOrDefault().TextField,



                           SupplierName = (tt.TravelTimeTypeID == (int)eDmc.Common.TraveltimeType.Between_Terminal_and_Terminal) ?
                           (from a in DB.T_DmcDataAirport
                            join at in DB.T_DmcDataAirportTerminal on a.AirportID equals at.AirportID
                            where a.AirportID == tt.VanueTwoID
                            select new
                            {
                                TextField = a.AirportName + "," + at.TerminalName
                            }).FirstOrDefault().TextField : (from sp in DB.T_DmcDataSupplier
                                                             join ct in DB.T_DmcDataCity on sp.CityID equals ct.CityID
                                                             where sp.SupplierID == tt.VanueTwoID
                                                             select new
                                                             {
                                                                 TextField = ct.CityName + "," + sp.SupplierName
                                                             }).FirstOrDefault().TextField

                       };

            repList.DataSource = eDmc.DBCommon.GetLinqWithPage(List);
            repList.DataBind();
        }
posted on 2009-01-13 16:54  prayforsmile  阅读(1960)  评论(0编辑  收藏  举报