2012-02-10 47 views
1

我試圖從使用LINQ服務器檢索的數據,大約有167條記錄在此表中,但是當我編譯代碼我收到總是這個錯誤:Linq To SQL:類型'System.OutOfMemoryException'的異常被拋出,我如何糾正這個錯誤?

Exception of type 'System.OutOfMemoryException' was thrown . 

在這裏,我張貼我使用的代碼(使用LinqPad):

var query1 = from c in TOUR_SIC_COST_ZEROs where c.ID ==2 

        select 
         new 
         { 
          c.ID, 
          c.Code, 
          c.CountryCode, 
          c.ProductTypeList, 
          c.KindOfTour00, 
          c.KindOfTour01, 
          c.KindOfTour02, 
          c.ClientName, 
          c.Status, 
          c.CurrencyCode, 
          c.TitleTour, 
           c.ItalianDay1, 
           c.ItalianDay2, 
           c.ItalianDay3, 
           c.ItalianDay4, 
           c.ItalianDay5, 
           c.ItalianDay6, 
           c.ItalianDay7, 
           c.ItalianDay8, 
           c.ItalianDay9, 
           c.ItalianDay10, 
           c.ItalianDay11, 
           c.ItalianDay12, 
           c.ItalianDay13, 
           c.ItalianDay14, 
           c.ItalianDay15, 
           c.ItalianDay16, 
           c.ItalianDay17, 
           c.ItalianDay18, 
           c.ItalianDay19, 
           c.ItalianDay20, 
           c.EnglishDay1, 
           c.EnglishDay2, 
           c.EnglishDay3, 
           c.EnglishDay4, 
           c.EnglishDay5, 
           c.EnglishDay6, 
           c.EnglishDay7, 
           c.EnglishDay8, 
           c.EnglishDay9, 
           c.EnglishDay10, 
           c.EnglishDay11, 
           c.EnglishDay12, 
           c.EnglishDay13, 
           c.EnglishDay14, 
           c.EnglishDay15, 
           c.EnglishDay16, 
           c.EnglishDay17, 
           c.EnglishDay18, 
           c.EnglishDay19, 
           c.EnglishDay20, 
           c.FrenchDay1, 
           c.FrenchDay2, 
           c.FrenchDay3, 
           c.FrenchDay4, 
           c.FrenchDay5, 
           c.FrenchDay6, 
           c.FrenchDay7, 
           c.FrenchDay8, 
           c.FrenchDay9, 
           c.FrenchDay10, 
           c.FrenchDay11, 
           c.FrenchDay12, 
           c.FrenchDay13, 
           c.FrenchDay14, 
           c.FrenchDay15, 
           c.FrenchDay16, 
           c.FrenchDay17, 
           c.FrenchDay18, 
           c.FrenchDay19, 
           c.FrenchDay20, 
           c.SpanishDay1, 
           c.SpanishDay2, 
           c.SpanishDay3, 
           c.SpanishDay4, 
           c.SpanishDay5, 
           c.SpanishDay6, 
           c.SpanishDay7, 
           c.SpanishDay8, 
           c.SpanishDay9, 
           c.SpanishDay10, 
           c.SpanishDay11, 
           c.SpanishDay12, 
           c.SpanishDay13, 
           c.SpanishDay14, 
           c.SpanishDay15, 
           c.SpanishDay16, 
           c.SpanishDay17, 
           c.SpanishDay18, 
           c.SpanishDay19, 
           c.SpanishDay20, 

         /* c._1Pax_Del, 
          c._2Pax_Del, 
          c._3_5Pax_Del, 
          c._6_9Pax_Del, 
          c._10_14Pax_Del, 
          c._15_19Pax_Del, 
          c._20_29Pax_Del, 
          c._30_40Pax_Del, 
          c._Sup_SGL_Del, 
          c._Red_3rd_pers_Del, 
          c._1Pax_Sup, 
          c._2Pax_Sup, 
          c._3_5Pax_Sup, 
          c._6_9Pax_Sup, 
          c._10_14Pax_Sup, 
          c._15_19Pax_Sup, 
          c._20_29Pax_Sup, 
          c._30_40Pax_Sup, 
          c._Sup_SGL_Sup, 
          c._Red_3rd_pers_Sup, 
          c._1Pax_1Cat, 
          c._2Pax_1Cat, 
          c._3_5Pax_1Cat, 
          c._6_9Pax_1Cat, 
          c._10_14Pax_1Cat, 
          c._15_19Pax_1Cat, 
          c._20_29Pax_1Cat, 
          c._30_40Pax_1Cat, 
          c._Sup_SGL_1Cat, 
          c._Red_3rd_pers_1Cat, 
          c._1Pax_Smart, 
          c._2Pax_Smart, 
          c._3_5Pax_Smart, 
          c._6_9Pax_Smart, 
          c._10_14Pax_Smart, 
          c._15_19Pax_Smart, 
          c._20_29Pax_Smart, 
          c._30_40Pax_Smart, 
          c._Sup_SGL_Smart, 
          c._Red_3rd_pers_Smart, 
          c._1Pax_Mixed, 
          c._2Pax_Mixed, 
          c._3_5Pax_Mixed, 
          c._6_9Pax_Mixed, 
          c._10_14Pax_Mixed, 
          c._15_19Pax_Mixed, 
          c._20_29Pax_Mixed, 
          c._30_40Pax_Mixed, 
          c._Sup_SGL_Mixed, 
          c._Red_3rd_pers_Mixed, 
          c._1Pax_Tailor, 
          c._2Pax_Tailor, 
          c._3_5Pax_Tailor, 
          c._6_9Pax_Tailor, 
          c._10_14Pax_Tailor, 
          c._15_19Pax_Tailor, 
          c._20_29Pax_Tailor, 
          c._30_40Pax_Tailor, 
          c._Sup_SGL_Tailor, 
          c._Red_3rd_pers_Tailor, 
          c.Promotion_1, 
          c.Promotion1_ValidFrom, 
          c.Promotion1_ValidTo, 
          c.PromotionFormula1, 
          c.PromotionRoomPerc_1, 
          c.PromotionRoomPrice_1, 
          c.IsDecrease_1, 
          c.IsIncrease_1, 
          c.IsDefault_1, 
          c.Promotion_2, 
          c.Promotion2_ValidFrom, 
          c.Promotion2_ValidTo, 
          c.PromotionFormula2, 
          c.PromotionRoomPerc_2, 
          c.PromotionRoomPrice_2, 
          c.IsDecrease_2, 
          c.IsIncrease_2, 
          c.IsDefault_2, 
          c.Promotion_3, 
          c.Promotion3_ValidFrom, 
          c.Promotion3_ValidTo, 
          c.PromotionFormula3, 
          c.PromotionRoomPerc_3, 
          c.PromotionRoomPrice_3, 
          c.IsDecrease_3, 
          c.IsIncrease_3, 
          c.IsDefault_3, 
          c.Promotion_4, 
          c.Promotion4_ValidFrom, 
          c.Promotion4_ValidTo, 
          c.PromotionFormula4, 
          c.PromotionRoomPerc_4, 
          c.PromotionRoomPrice_4, 
          c.IsDecrease_4, 
          c.IsIncrease_4, 
          c.IsDefault_4, 
          c.Promotion_5, 
          c.Promotion5_ValidFrom, 
          c.Promotion5_ValidTo, 
          c.PromotionFormula5, 
          c.PromotionRoomPerc_5, 
          c.PromotionRoomPrice_5, 
          c.IsDecrease_5, 
          c.IsIncrease_5, 
          c.IsDefault_5, 
          c.Promotion_6, 
          c.Promotion6_ValidFrom, 
          c.Promotion6_ValidTo, 
          c.PromotionFormula6, 
          c.PromotionRoomPerc_6, 
          c.PromotionRoomPrice_6, 
          c.IsDecrease_6, 
          c.IsIncrease_6, 
          c.IsDefault_6, 
          c.Promotion_7, 
          c.Promotion7_ValidFrom, 
          c.Promotion7_ValidTo, 
          c.PromotionFormula7, 
          c.PromotionRoomPerc_7, 
          c.PromotionRoomPrice_7, 
          c.IsDecrease_7, 
          c.IsIncrease_7, 
          c.IsDefault_7,*/ 
          c.CityCode1, 
          c.CityCode2, 
          c.CityCode3, 
          c.CityCode4, 
          c.CityCode5, 
          c.CityCode6, 
          c.CityCode7, 
          c.CityCode8, 
          c.CityCode9, 
          c.CityCode10, 
          c.CityCode11, 

          c.Note, 
          c.UserCreated, 
          c.DateCreated, 
          c.UserModified, 
          c.DateModified 
         }; 
         var query2 = from c in TOUR_SIC_COST_ZEROs where c.ID==2 
         select new 
         { 
         c.ID, 
         c._1Pax_Del, 
          c._2Pax_Del, 
          c._3_5Pax_Del, 
          c._6_9Pax_Del, 
          c._10_14Pax_Del, 
          c._15_19Pax_Del, 
          c._20_29Pax_Del, 
          c._30_40Pax_Del, 
          c._Sup_SGL_Del, 
          c._Red_3rd_pers_Del, 
          c._1Pax_Sup, 
          c._2Pax_Sup, 
          c._3_5Pax_Sup, 
          c._6_9Pax_Sup, 
          c._10_14Pax_Sup, 
          c._15_19Pax_Sup, 
          c._20_29Pax_Sup, 
          c._30_40Pax_Sup, 
          c._Sup_SGL_Sup, 
          c._Red_3rd_pers_Sup, 
          c._1Pax_1Cat, 
          c._2Pax_1Cat, 
          c._3_5Pax_1Cat, 
          c._6_9Pax_1Cat, 
          c._10_14Pax_1Cat, 
          c._15_19Pax_1Cat, 
          c._20_29Pax_1Cat, 
          c._30_40Pax_1Cat, 
          c._Sup_SGL_1Cat, 
          c._Red_3rd_pers_1Cat, 
          c._1Pax_Smart, 
          c._2Pax_Smart, 
          c._3_5Pax_Smart, 
          c._6_9Pax_Smart, 
          c._10_14Pax_Smart, 
          c._15_19Pax_Smart, 
          c._20_29Pax_Smart, 
          c._30_40Pax_Smart, 
          c._Sup_SGL_Smart, 
          c._Red_3rd_pers_Smart, 
          c._1Pax_Mixed, 
          c._2Pax_Mixed, 
          c._3_5Pax_Mixed, 
          c._6_9Pax_Mixed, 
          c._10_14Pax_Mixed, 
          c._15_19Pax_Mixed, 
          c._20_29Pax_Mixed, 
          c._30_40Pax_Mixed, 
          c._Sup_SGL_Mixed, 
          c._Red_3rd_pers_Mixed, 
          c._1Pax_Tailor, 
          c._2Pax_Tailor, 
          c._3_5Pax_Tailor, 
          c._6_9Pax_Tailor, 
          c._10_14Pax_Tailor, 
          c._15_19Pax_Tailor, 
          c._20_29Pax_Tailor, 
          c._30_40Pax_Tailor, 
          c._Sup_SGL_Tailor, 
          c._Red_3rd_pers_Tailor, 
         }; 
         var total = from c in query1 where c.ID == 2 
         from d in query2.Where(a =>a.ID == c.ID) 
         select new 
         { 

         c.ID, 
          c.Code, 
          c.CountryCode, 
          c.ProductTypeList, 
          c.KindOfTour00, 
          c.KindOfTour01, 
          c.KindOfTour02, 
          c.ClientName, 
          c.Status, 
          c.CurrencyCode, 
          c.TitleTour, 
           c.ItalianDay1, 
           c.ItalianDay2, 
           c.ItalianDay3, 
           c.ItalianDay4, 
           c.ItalianDay5, 
           c.ItalianDay6, 
           c.ItalianDay7, 
           c.ItalianDay8, 
           c.ItalianDay9, 
           c.ItalianDay10, 
           c.ItalianDay11, 
           c.ItalianDay12, 
           c.ItalianDay13, 
           c.ItalianDay14, 
           c.ItalianDay15, 
           c.ItalianDay16, 
           c.ItalianDay17, 
           c.ItalianDay18, 
           c.ItalianDay19, 
           c.ItalianDay20, 
           c.EnglishDay1, 
           c.EnglishDay2, 
           c.EnglishDay3, 
           c.EnglishDay4, 
           c.EnglishDay5, 
           c.EnglishDay6, 
           c.EnglishDay7, 
           c.EnglishDay8, 
           c.EnglishDay9, 
           c.EnglishDay10, 
           c.EnglishDay11, 
           c.EnglishDay12, 
           c.EnglishDay13, 
           c.EnglishDay14, 
           c.EnglishDay15, 
           c.EnglishDay16, 
           c.EnglishDay17, 
           c.EnglishDay18, 
           c.EnglishDay19, 
           c.EnglishDay20, 
           c.FrenchDay1, 
           c.FrenchDay2, 
           c.FrenchDay3, 
           c.FrenchDay4, 
           c.FrenchDay5, 
           c.FrenchDay6, 
           c.FrenchDay7, 
           c.FrenchDay8, 
           c.FrenchDay9, 
           c.FrenchDay10, 
           c.FrenchDay11, 
           c.FrenchDay12, 
           c.FrenchDay13, 
           c.FrenchDay14, 
           c.FrenchDay15, 
           c.FrenchDay16, 
           c.FrenchDay17, 
           c.FrenchDay18, 
           c.FrenchDay19, 
           c.FrenchDay20, 
           c.SpanishDay1, 
           c.SpanishDay2, 
           c.SpanishDay3, 
           c.SpanishDay4, 
           c.SpanishDay5, 
           c.SpanishDay6, 
           c.SpanishDay7, 
           c.SpanishDay8, 
           c.SpanishDay9, 
           c.SpanishDay10, 
           c.SpanishDay11, 
           c.SpanishDay12, 
           c.SpanishDay13, 
           c.SpanishDay14, 
           c.SpanishDay15, 
           c.SpanishDay16, 
           c.SpanishDay17, 
           c.SpanishDay18, 
           c.SpanishDay19, 
           c.SpanishDay20, 

         d._1Pax_Del, 
          d._2Pax_Del, 
          d._3_5Pax_Del, 
          d._6_9Pax_Del, 
          d._10_14Pax_Del, 
          d._15_19Pax_Del, 
          d._20_29Pax_Del, 
          d._30_40Pax_Del, 
          d._Sup_SGL_Del, 
          d._Red_3rd_pers_Del, 
          d._1Pax_Sup, 
          d._2Pax_Sup, 
          d._3_5Pax_Sup, 
          d._6_9Pax_Sup, 
          d._10_14Pax_Sup, 
          d._15_19Pax_Sup, 
          d._20_29Pax_Sup, 
          d._30_40Pax_Sup, 
          d._Sup_SGL_Sup, 
          d._Red_3rd_pers_Sup, 
          d._1Pax_1Cat, 
          d._2Pax_1Cat, 
          d._3_5Pax_1Cat, 
          d._6_9Pax_1Cat, 
          d._10_14Pax_1Cat, 
          d._15_19Pax_1Cat, 
          d._20_29Pax_1Cat, 
          d._30_40Pax_1Cat, 
          d._Sup_SGL_1Cat, 
          d._Red_3rd_pers_1Cat, 
          d._1Pax_Smart, 
          d._2Pax_Smart, 
          d._3_5Pax_Smart, 
          d._6_9Pax_Smart, 
          d._10_14Pax_Smart, 
          d._15_19Pax_Smart, 
          d._20_29Pax_Smart, 
          d._30_40Pax_Smart, 
          d._Sup_SGL_Smart, 
          d._Red_3rd_pers_Smart, 
          d._1Pax_Mixed, 
          d._2Pax_Mixed, 
          d._3_5Pax_Mixed, 
          d._6_9Pax_Mixed, 
          d._10_14Pax_Mixed, 
          d._15_19Pax_Mixed, 
          d._20_29Pax_Mixed, 
          d._30_40Pax_Mixed, 
          d._Sup_SGL_Mixed, 
          d._Red_3rd_pers_Mixed, 
          d._1Pax_Tailor, 
          d._2Pax_Tailor, 
          d._3_5Pax_Tailor, 
          d._6_9Pax_Tailor, 
          d._10_14Pax_Tailor, 
          d._15_19Pax_Tailor, 
          d._20_29Pax_Tailor, 
          d._30_40Pax_Tailor, 
          d._Sup_SGL_Tailor, 
          d._Red_3rd_pers_Tailor, 
         /* c.Promotion_1, 
          c.Promotion1_ValidFrom, 
          c.Promotion1_ValidTo, 
          c.PromotionFormula1, 
          c.PromotionRoomPerc_1, 
          c.PromotionRoomPrice_1, 
          c.IsDecrease_1, 
          c.IsIncrease_1, 
          c.IsDefault_1, 
          c.Promotion_2, 
          c.Promotion2_ValidFrom, 
          c.Promotion2_ValidTo, 
          c.PromotionFormula2, 
          c.PromotionRoomPerc_2, 
          c.PromotionRoomPrice_2, 
          c.IsDecrease_2, 
          c.IsIncrease_2, 
          c.IsDefault_2, 
          c.Promotion_3, 
          c.Promotion3_ValidFrom, 
          c.Promotion3_ValidTo, 
          c.PromotionFormula3, 
          c.PromotionRoomPerc_3, 
          c.PromotionRoomPrice_3, 
          c.IsDecrease_3, 
          c.IsIncrease_3, 
          c.IsDefault_3, 
          c.Promotion_4, 
          c.Promotion4_ValidFrom, 
          c.Promotion4_ValidTo, 
          c.PromotionFormula4, 
          c.PromotionRoomPerc_4, 
          c.PromotionRoomPrice_4, 
          c.IsDecrease_4, 
          c.IsIncrease_4, 
          c.IsDefault_4, 
          c.Promotion_5, 
          c.Promotion5_ValidFrom, 
          c.Promotion5_ValidTo, 
          c.PromotionFormula5, 
          c.PromotionRoomPerc_5, 
          c.PromotionRoomPrice_5, 
          c.IsDecrease_5, 
          c.IsIncrease_5, 
          c.IsDefault_5, 
          c.Promotion_6, 
          c.Promotion6_ValidFrom, 
          c.Promotion6_ValidTo, 
          c.PromotionFormula6, 
          c.PromotionRoomPerc_6, 
          c.PromotionRoomPrice_6, 
          c.IsDecrease_6, 
          c.IsIncrease_6, 
          c.IsDefault_6, 
          c.Promotion_7, 
          c.Promotion7_ValidFrom, 
          c.Promotion7_ValidTo, 
          c.PromotionFormula7, 
          c.PromotionRoomPerc_7, 
          c.PromotionRoomPrice_7, 
          c.IsDecrease_7, 
          c.IsIncrease_7, 
          c.IsDefault_7,*/ 
          c.CityCode1, 
          c.CityCode2, 
          c.CityCode3, 
          c.CityCode4, 
          c.CityCode5, 
          c.CityCode6, 
          c.CityCode7, 
          c.CityCode8, 
          c.CityCode9, 
          c.CityCode10, 
          c.CityCode11, 

          c.Note, 
          c.UserCreated, 
          c.DateCreated, 
          c.UserModified, 
          c.DateModified 
         }; 
         total.Dump(); 

你知道如何解決這一步嗎?

非常感謝您的關注。

乾杯

+3

我喔我的我錯過了一個心臟跳動 – V4Vendetta 2012-02-10 07:08:41

+0

@ V4Vendetta,hahahahaha – JayJay 2012-02-10 07:21:34

+3

我用盡內存試圖閱讀此... – 2012-02-10 08:29:17

回答

2

在最後一次查詢使用QUERY1和QUERY2之前你爲什麼不把ToList()方法,這可能會解決您的問題.....

var query1 = (from dad in data select d).ToList(); 
+0

,是的,它是正確的,非常感謝你的非常快速的答覆...有一個很好的天 – JayJay 2012-02-10 07:20:26

相關問題