Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 长查询原因System.StackOverflowException_C#_Visual Studio 2010_Linq To Sql - Fatal编程技术网

C# 长查询原因System.StackOverflowException

C# 长查询原因System.StackOverflowException,c#,visual-studio-2010,linq-to-sql,C#,Visual Studio 2010,Linq To Sql,我在Linq to Sql中有一个很长的查询,用于填充DataGrid,如下所示: var query = from c in dc.Hotel_Meals_TBLs select new { Code = c.HotelCodePrimary, CountryCode = c.CountryCode, CityCode = c.CityCode, HotelCode = c.HotelCode, Stars = c.StarCode, WWW

我在Linq to Sql中有一个很长的查询,用于填充DataGrid,如下所示:

var query = from c in dc.Hotel_Meals_TBLs 
select new
{
    Code = c.HotelCodePrimary,
    CountryCode = c.CountryCode,
    CityCode = c.CityCode,
    HotelCode = c.HotelCode,
    Stars = c.StarCode,
    WWW = c.WWWCode,
    ABF = c.ABFCode,
    Location = c.LocationCode,
    Currency = c.CurrencyCode,
    CodeCode = c.HotelCode,
    No = c.NoCode,
    HotelName = c.HotelName,
    HFROM = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._From,
    HTO = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._To,
    HFROM2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(1).Take(1).First()._From,
    HTO2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(1).Take(1).First()._To,
    HFROM3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(2).Take(1).First()._From,
    HTO3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(2).Take(1).First()._To,
    HFROM4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(3).Take(1).First()._From,
    HTO4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(3).Take(1).First()._To,
    HFROM5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(4).Take(1).First()._From,
    HTO5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(4).Take(1).First()._To,
    HFROM6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(5).Take(1).First()._From,
    HTO6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(5).Take(1).First()._To,
    HFROM7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(6).Take(1).First()._From,
    HTO7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(6).Take(1).First()._To,
    HFROM8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(7).Take(1).First()._From,
    HTO8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(7).Take(1).First()._To,
    HFROM9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(8).Take(1).First()._From,
    HTO9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(8).Take(1).First()._To,
    HFROM10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(9).Take(1).First()._From,
    HTO10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High")).Skip(9).Take(1).First()._To,
    PFROM = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._From,
    PTO = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._To,
    PFROM2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(1).Take(1).First()._From,
    PTO2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(1).Take(1).First()._To,
    PFROM3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(2).Take(1).First()._From,
    PTO3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(2).Take(1).First()._To,
    PFROM4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(3).Take(1).First()._From,
    PTO4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(3).Take(1).First()._To,
    PFROM5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(4).Take(1).First()._From,
    PTO5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(4).Take(1).First()._To,
    PFROM6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(5).Take(1).First()._From,
    PTO6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(5).Take(1).First()._To,
    PFROM7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(6).Take(1).First()._From,
    PTO7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(6).Take(1).First()._To,
    PFROM8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(7).Take(1).First()._From,
    PTO8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(7).Take(1).First()._To,
    PFROM9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(8).Take(1).First()._From,
    PTO9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(8).Take(1).First()._To,
    PFROM10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(9).Take(1).First()._From,
    PTO10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Peak")).Skip(9).Take(1).First()._To,
    TPFROM = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._From,
    TPTO = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._To,
    TPFROM2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).Skip(1).Take(1).First()._From,
    TPTO2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).Skip(1).Take(1).First()._To,
    TPFROM3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).Skip(2).Take(1).First()._From,
    TPTO3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("ExtraPeak")).Skip(2).Take(1).First()._To,
    SFROM = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._From,
    STO = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._To,
    SFROM2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).Skip(1).Take(1).First()._From,
    STO2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).Skip(1).Take(1).First()._To,
    SFROM3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).Skip(2).Take(1).First()._From,
    STO3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Shoulder")).Skip(2).Take(1).First()._To,
    LFROM = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._From,
    LTO = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID)._To,
    LFROM2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(1).Take(1).First()._From,
    LTO2 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(1).Take(1).First()._To,
    LFROM3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(2).Take(1).First()._From,
    LTO3 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(2).Take(1).First()._To,
    LFROM4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(3).Take(1).First()._From,
    LTO4 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(3).Take(1).First()._To,
    LFROM5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(4).Take(1).First()._From,
    LTO5 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(4).Take(1).First()._To,
    LFROM6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(5).Take(1).First()._From,
    LTO6 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(5).Take(1).First()._To,
    LFROM7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(6).Take(1).First()._From,
    LTO7 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(6).Take(1).First()._To,
    LFROM8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(7).Take(1).First()._From,
    LTO8 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(7).Take(1).First()._To,
    LFROM9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(8).Take(1).First()._From,
    LTO9 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(8).Take(1).First()._To,
    LFROM10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(9).Take(1).First()._From,
    LTO10 = c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("Low")).Skip(9).Take(1).First()._To,
    BF = c.Breakfast,
    LUN = c.Lunch,
    DIN = c.Dinner,
    _24Dec = c._24Dec,
    _31Dec = c._31Dec,
    ROOM1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).RoomName,
    SGLH1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).SGL_HighSeason,
    DBLH1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).DBL_HighSeason,
    TPLH1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).TPL_HighSeason,
    SGLP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).SGL_PeakSeason,
    DBLP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).DBL_PeakSeason,
    TPLP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).TPL_PeakSeason,
    SGLTP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).SGL_TopPeakSeason,
    DBLTP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).DBL_TopPeakSeason,
    TPLTP1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).TPL_TopPeakSeason,
    SGLS1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).SGL_ShoulderSeason,
    DBLS1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).DBL_ShoulderSeason,
    TPLS1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).TPL_ShoulderSeason,
    SGLL1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).SGL_LowSeason,
    DBLL1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).DBL_LowSeason,
    TPLL1 = c.HotelRoom_TBLs.FirstOrDefault(a => a.HotelCodeID == c.HotelCodeID).TPL_LowSeason,
    ROOM2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().RoomName,
    SGLH2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().SGL_HighSeason,
    DBLH2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().DBL_HighSeason,
    TPLH2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().TPL_HighSeason,
    SGLP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().SGL_PeakSeason,
    DBLP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().DBL_PeakSeason,
    TPLP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().TPL_PeakSeason,
    SGLTP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().SGL_TopPeakSeason,
    DBLTP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().DBL_TopPeakSeason,
    TPLTP2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().TPL_TopPeakSeason,
    SGLS2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().SGL_ShoulderSeason,
    DBLS2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().DBL_ShoulderSeason,
    TPLS2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().TPL_ShoulderSeason,
    SGLL2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().SGL_LowSeason,
    DBLL2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().DBL_LowSeason,
    TPLL2 = c.HotelRoom_TBLs.Skip(1).Take(1).First().TPL_LowSeason,
    ROOM3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().RoomName,
    SGLH3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().SGL_HighSeason,
    DBLH3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().DBL_HighSeason,
    TPLH3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().TPL_HighSeason,
    SGLP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().SGL_PeakSeason,
    DBLP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().DBL_PeakSeason,
    TPLP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().TPL_PeakSeason,
    SGLTP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().SGL_TopPeakSeason,
    DBLTP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().DBL_TopPeakSeason,
    TPLTP3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().TPL_TopPeakSeason,
    SGLS3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().SGL_ShoulderSeason,
    DBLS3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().DBL_ShoulderSeason,
    TPLS3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().TPL_ShoulderSeason,
    SGLL3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().SGL_LowSeason,
    DBLL3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().DBL_LowSeason,
    TPLL3 = c.HotelRoom_TBLs.Skip(2).Take(1).First().TPL_LowSeason,
    ROOM4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().RoomName,
    SGLH4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().SGL_HighSeason,
    DBLH4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().DBL_HighSeason,
    TPLH4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().TPL_HighSeason,
    SGLP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().SGL_PeakSeason,
    DBLP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().DBL_PeakSeason,
    TPLP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().TPL_PeakSeason,
    SGLTP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().SGL_TopPeakSeason,
    DBLTP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().DBL_TopPeakSeason,
    TPLTP4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().TPL_TopPeakSeason,
    SGLS4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().SGL_ShoulderSeason,
    DBLS4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().DBL_ShoulderSeason,
    TPLS4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().TPL_ShoulderSeason,
    SGLL4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().SGL_LowSeason,
    DBLL4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().DBL_LowSeason,
    TPLL4 = c.HotelRoom_TBLs.Skip(3).Take(1).First().TPL_LowSeason,
    ROOM5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().RoomName,
    SGLH5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().SGL_HighSeason,
    DBLH5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().DBL_HighSeason,
    TPLH5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().TPL_HighSeason,
    SGLP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().SGL_PeakSeason,
    DBLP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().DBL_PeakSeason,
    TPLP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().TPL_PeakSeason,
    SGLTP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().SGL_TopPeakSeason,
    DBLTP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().DBL_TopPeakSeason,
    TPLTP5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().TPL_TopPeakSeason,
    SGLS5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().SGL_ShoulderSeason,
    DBLS5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().DBL_ShoulderSeason,
    TPLS5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().TPL_ShoulderSeason,
    SGLL5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().SGL_LowSeason,
    DBLL5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().DBL_LowSeason,
    TPLL5 = c.HotelRoom_TBLs.Skip(4).Take(1).First().TPL_LowSeason,
    ROOM6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().RoomName,
    SGLH6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().SGL_HighSeason,
    DBLH6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().DBL_HighSeason,
    TPLH6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().TPL_HighSeason,
    SGLP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().SGL_PeakSeason,
    DBLP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().DBL_PeakSeason,
    TPLP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().TPL_PeakSeason,
    SGLTP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().SGL_TopPeakSeason,
    DBLTP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().DBL_TopPeakSeason,
    TPLTP6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().TPL_TopPeakSeason,
    SGLS6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().SGL_ShoulderSeason,
    DBLS6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().DBL_ShoulderSeason,
    TPLS6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().TPL_ShoulderSeason,
    SGLL6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().SGL_LowSeason,
    DBLL6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().DBL_LowSeason,
    TPLL6 = c.HotelRoom_TBLs.Skip(5).Take(1).First().TPL_LowSeason,
    ROOM7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().RoomName,
    SGLH7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().SGL_HighSeason,
    DBLH7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().DBL_HighSeason,
    TPLH7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().TPL_HighSeason,
    SGLP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().SGL_PeakSeason,
    DBLP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().DBL_PeakSeason,
    TPLP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().TPL_PeakSeason,
    SGLTP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().SGL_TopPeakSeason,
    DBLTP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().DBL_TopPeakSeason,
    TPLTP7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().TPL_TopPeakSeason,
    SGLS7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().SGL_ShoulderSeason,
    DBLS7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().DBL_ShoulderSeason,
    TPLS7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().TPL_ShoulderSeason,
    SGLL7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().SGL_LowSeason,
    DBLL7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().DBL_LowSeason,
    TPLL7 = c.HotelRoom_TBLs.Skip(6).Take(1).First().TPL_LowSeason,
    ROOM8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().RoomName,
    SGLH8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().SGL_HighSeason,
    DBLH8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().DBL_HighSeason,
    TPLH8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().TPL_HighSeason,
    SGLP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().SGL_PeakSeason,
    DBLP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().DBL_PeakSeason,
    TPLP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().TPL_PeakSeason,
    SGLTP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().SGL_TopPeakSeason,
    DBLTP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().DBL_TopPeakSeason,
    TPLTP8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().TPL_TopPeakSeason,
    SGLS8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().SGL_ShoulderSeason,
    DBLS8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().DBL_ShoulderSeason,
    TPLS8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().TPL_ShoulderSeason,
    SGLL8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().SGL_LowSeason,
    DBLL8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().DBL_LowSeason,
    TPLL8 = c.HotelRoom_TBLs.Skip(7).Take(1).First().TPL_LowSeason,
    CivicNumber =c.Number,
    Street =c.Street,
    District =c.District,
    City =c.City,
    Country =c.Country,
    Tel =c.Tel,
    Fax =c.Fax,
    TotalRoom =c.TotalRoom,
    RoomFacilities =c.RoomFacilities,
    RestaurantBar =c.Restaurant_Bar,
    HotelFacilities =c.HotelFacilities,
    GM = c.HotelContact_TBLs.Where(d => d.ContactType.Contains("GM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Name,
    GMMobile = c.HotelContact_TBLs.Where(d => d.ContactType.Contains("GM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Mobile,
    GMDirectTel = c.HotelContact_TBLs.Where(d => d.ContactType.Contains("GM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).DirectTel,
    GMDirectFax = c.HotelContact_TBLs.Where(d => d.ContactType.Contains("GM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).DirectFax,
    GMEmail = c.HotelContact_TBLs.Where(d => d.ContactType.Contains("GM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Email,
    DirectorFB = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("Dir")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Name,
    DirMobile = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("Dir")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Mobile,
    DirEmail = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("Dir")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Email,
    DOS = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("DOS")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Name,
    DOSMobile =  c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("DOS")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Mobile,
    DOSEmail =  c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("DOS")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Email,
    DOSSkype =  c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("DOS")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Skype,
    SM =  c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("SM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Name,
    SMMobile = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("SM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Mobile,
    SMEmail = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("SM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Email,
    SMSkype =c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("SM")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Skype,
    RSVN = c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("RSVN")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Name,
    RSVNMobile =c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("RSVN")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Mobile,
    RSVNEmail =c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("RSVN")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Email,
    RSVNSkype =c.HotelContact_TBLs.Where(d => d.ContactType.StartsWith("RSVN")).SingleOrDefault(a => a.HotelCodeID == c.HotelCodeID).Skype,
    FocPolicy = c.FocPolicy,
    ChildPolicy = c.ChildPolicy,
    HoneyMoon = c.HoneyMoon,
    CancellationPolicy = c.CancellationPolicy,
    PaymentTerm = c.PaymentTerm,
    BankReference = c.BankReference,
    Notes = c.Note
}
但当我使用Visual Studio 2010编译它时,我收到以下错误消息:

匿名托管的DynamicMethods程序集中发生类型为“System.StackOverflowException”的未处理异常;{无法计算表达式,因为当前线程处于堆栈溢出状态。}


我也用LinqPad4编译了这个查询,没有错误,你知道这个消息是什么意思吗?

我建议你重写查询以减少内存分配。 看,在你写的每一行中:

c.HotelPeriod_TBLs.Where(d => d.PeriodName.Contains("High"))
// equal lines of code here.

我认为这是你提问的主要问题。尝试不在一个查询中填充数据,或将此查询移动到SQL层。这个怪物不会活很长时间,会产生巨大的内存问题。

您是从哪种应用程序运行此查询的?Windows窗体应用程序或ASP.NET页面?你能告诉我们你是如何从代码中执行查询的吗?@JayJay-你真的需要在网格中显示这么多列吗?@Davide,你好,先生,我正在开发一个WPF应用程序,查询将按如下方式完成:this.xamHotel.DataContext=query.ToList();填充数据网格;不管怎样,如果你需要更多的解释,我会与你分享,Thanks@Giorgi,您好,先生,我需要在DataGrid中显示255列,然后将数据转换为Excel,以便客户要求,我知道这太多了,但这不取决于我;p我个人会重写;我怀疑skip(n).take(1)通过一个groupby,可能还有2个(或更多)查询/数据块缝合在一起,工作会更好。在这种复杂程度上,我也会写TSQL而不是LINQthanks先生,我会控制它,然后告诉你结果。你为什么认为内存是个问题?那一行代码是在哪里分配大量内存的?这一行甚至没有被执行,它被翻译成了SQL。我认为内存问题恰恰是在编译LINQ到SQL命令时出现的。@VMAtm,你能详细说明一下吗?我很好奇你到底认为问题出在哪里。