2016-06-20 5 views
-1

entityframework에 문제가 있습니다. 재귀 루프가 쿼리에 존재하지만 왜이 예외에 직면하는지 모르겠습니다. 코드를 볼 수 있습니다. 내가 우체부를 통해이 문제를 테스트 할 때System.StackOverflowException 'EntityFramework.dll에서 발생했습니다.

var checkList = from checklist in db.Checklists 
         join code in db.Codes on checklist.iCodeID equals code.iCodeID 
         where code.bDeleted == false && code.bObsolete == false 
         join codeGroup in db.CodeGroups on code.iGroupID equals codeGroup.iGroupID 
         where codeGroup.bDeleted == false && codeGroup.bInspection == true 
         join codeInspectionType in db.CodeInspectionTypeVs on checklist.LongKey.Substring(0, 6) equals DbFunctions.Right("00000" + codeInspectionType.InspectionTypeID, 6) 
         where checklist.bDeleted == false 
         orderby checklist.iChecklistID 
         select new 
         { 
          checklist.iChecklistID, 
          InspectionTypeID = checklist.LongKey.Substring(0, 6).ToString(), 
          codeInspectionType.bSubInspection, 
          SortSeq = db.CodesTreeSelectUDF(null, checklist.LongKey, null, null, null).Select(x => x.SortKey).FirstOrDefault(), 
          codeGroup.iGroupID, 
          codeGroup.GroupDesc, 
          checklist.bPromptForQty, 
          checklist.bShowInTree, 
          DescCombo = new { codeGroup.DescCombo1, codeGroup.DescCombo2, codeGroup.DescCombo3, codeGroup.DescCombo4, codeGroup.DescCombo5, codeGroup.DescCombo6, codeGroup.DescCombo7, codeGroup.DescCombo8, codeGroup.DescCombo9, codeGroup.DescCombo10, codeGroup.DescCombo11, codeGroup.DescCombo12, codeGroup.DescCombo13, codeGroup.DescCombo14, codeGroup.DescCombo15, codeGroup.DescCombo16, codeGroup.DescCombo17, codeGroup.DescCombo18, codeGroup.DescCombo19, codeGroup.DescCombo20, codeGroup.DescCombo21, codeGroup.DescCombo22, codeGroup.DescCombo23, codeGroup.DescCombo24, codeGroup.DescCombo25, codeGroup.DescCombo26, codeGroup.DescCombo27, codeGroup.DescCombo28, codeGroup.DescCombo29, codeGroup.DescCombo30 }, 
          codeGroup.DescText1, 
          codeGroup.bTextAbbreviation1, 
          codeGroup.DescText2, 
          codeGroup.bTextAbbreviation2, 
          codeGroup.DescText3, 
          codeGroup.bTextAbbreviation3, 
          codeGroup.DescText4, 
          codeGroup.bTextAbbreviation4, 
          codeGroup.DescText5, 
          codeGroup.bTextAbbreviation5, 
          codeGroup.DescText6, 
          codeGroup.bTextAbbreviation6, 
          codeGroup.DescText7, 
          codeGroup.bTextAbbreviation7, 
          codeGroup.DescText8, 
          codeGroup.bTextAbbreviation8, 
          codeGroup.DescText9, 
          codeGroup.bTextAbbreviation9, 
          codeGroup.DescText10, 
          codeGroup.bTextAbbreviation10, 
          codeGroup.DescInt1, 
          codeGroup.DescInt2, 
          codeGroup.DescInt3, 
          codeGroup.DescInt4, 
          codeGroup.DescInt5, 
          codeGroup.DescInt6, 
          codeGroup.DescInt7, 
          codeGroup.DescInt8, 
          codeGroup.DescInt9, 
          codeGroup.DescInt10, 
          codeGroup.DescNum1, 
          codeGroup.DescNum2, 
          codeGroup.DescNum3, 
          codeGroup.DescNum4, 
          codeGroup.DescNum5, 
          codeGroup.DescNum6, 
          codeGroup.DescNum7, 
          codeGroup.DescNum8, 
          codeGroup.DescNum9, 
          codeGroup.DescNum10, 
          codeGroup.DescBool1, 
          codeGroup.BoolOnText1, 
          codeGroup.BoolOffText1, 
          codeGroup.DescBool2, 
          codeGroup.BoolOnText2, 
          codeGroup.BoolOffText2, 
          codeGroup.DescBool3, 
          codeGroup.BoolOnText3, 
          codeGroup.BoolOffText3, 
          codeGroup.DescBool4, 
          codeGroup.BoolOnText4, 
          codeGroup.BoolOffText4, 
          codeGroup.DescBool5, 
          codeGroup.BoolOnText5, 
          codeGroup.BoolOffText5, 
          codeGroup.DescBool6, 
          codeGroup.BoolOnText6, 
          codeGroup.BoolOffText6, 
          codeGroup.DescBool7, 
          codeGroup.BoolOnText7, 
          codeGroup.BoolOffText7, 
          codeGroup.DescBool8, 
          codeGroup.BoolOnText8, 
          codeGroup.BoolOffText8, 
          codeGroup.DescBool9, 
          codeGroup.BoolOnText9, 
          codeGroup.BoolOffText9, 
          codeGroup.DescBool10, 
          codeGroup.BoolOnText10, 
          codeGroup.BoolOffText10, 
          codeGroup.DescBool11, 
          codeGroup.BoolOnText11, 
          codeGroup.BoolOffText11, 
          codeGroup.DescBool12, 
          codeGroup.BoolOnText12, 
          codeGroup.BoolOffText12, 
          codeGroup.DescBool13, 
          codeGroup.BoolOnText13, 
          codeGroup.BoolOffText13, 
          codeGroup.DescBool14, 
          codeGroup.BoolOnText14, 
          codeGroup.BoolOffText14, 
          codeGroup.DescBool15, 
          codeGroup.BoolOnText15, 
          codeGroup.BoolOffText15, 
          codeGroup.DescBool16, 
          codeGroup.BoolOnText16, 
          codeGroup.BoolOffText16, 
          codeGroup.DescBool17, 
          codeGroup.BoolOnText17, 
          codeGroup.BoolOffText17, 
          codeGroup.DescBool18, 
          codeGroup.BoolOnText18, 
          codeGroup.BoolOffText18, 
          codeGroup.DescBool19, 
          codeGroup.BoolOnText19, 
          codeGroup.BoolOffText19, 
          codeGroup.DescBool20, 
          codeGroup.BoolOnText20, 
          codeGroup.BoolOffText20, 
          codeGroup.DescBool21, 
          codeGroup.BoolOnText21, 
          codeGroup.BoolOffText21, 
          codeGroup.DescBool22, 
          codeGroup.BoolOnText22, 
          codeGroup.BoolOffText22, 
          codeGroup.DescBool23, 
          codeGroup.BoolOnText23, 
          codeGroup.BoolOffText23, 
          codeGroup.DescBool24, 
          codeGroup.BoolOnText24, 
          codeGroup.BoolOffText24, 
          codeGroup.DescBool25, 
          codeGroup.BoolOnText25, 
          codeGroup.BoolOffText25, 
          codeGroup.DescBool26, 
          codeGroup.BoolOnText26, 
          codeGroup.BoolOffText26, 
          codeGroup.DescBool27, 
          codeGroup.BoolOnText27, 
          codeGroup.BoolOffText27, 
          codeGroup.DescBool28, 
          codeGroup.BoolOnText28, 
          codeGroup.BoolOffText28, 
          codeGroup.DescBool29, 
          codeGroup.BoolOnText29, 
          codeGroup.BoolOffText29, 
          codeGroup.DescBool30, 
          codeGroup.BoolOnText30, 
          codeGroup.BoolOffText30, 
          DescMoney = new { codeGroup.DescMoney1, codeGroup.DescMoney2, codeGroup.DescMoney3, codeGroup.DescMoney4, codeGroup.DescMoney5, codeGroup.DescMoney6, codeGroup.DescMoney7, codeGroup.DescMoney8, codeGroup.DescMoney9, codeGroup.DescMoney10 }, 
          DescDate = new { codeGroup.DescDate1, codeGroup.DescDate2, codeGroup.DescDate3, codeGroup.DescDate4, codeGroup.DescDate5, codeGroup.DescDate6, codeGroup.DescDate7, codeGroup.DescDate8, codeGroup.DescDate9, codeGroup.DescDate10 }, 
          DescMemo = new { codeGroup.DescMemo1, codeGroup.DescMemo2, codeGroup.DescMemo3, codeGroup.DescMemo4, codeGroup.DescMemo5, codeGroup.DescMemo6, codeGroup.DescMemo7, codeGroup.DescMemo8, codeGroup.DescMemo9, codeGroup.DescMemo10 }, 
          codeGroup.Bookmark, 
          codeGroup.bProtected, 
          codeGroup.bMultiPicklist, 
          codeGroup.Notes, 
          code.iCodeID, 
          LongKey = db.CodesTreeSelectUDF(null, checklist.LongKey, null, null, null).Select(x => x.LongKey).FirstOrDefault(), 
          code.CodeSortCode, 
          code.Description, 
          code.bDefault, 
          CodeCombo = new 
          { 
           code.CodeCombo1, 
           code.CodeCombo2, 
           code.CodeCombo3, 
           code.CodeCombo4, 
           code.CodeCombo5, 
           code.CodeCombo6, 
           code.CodeCombo7, 
           code.CodeCombo8, 
           code.CodeCombo9, 
           code.CodeCombo10, 
           code.CodeCombo11, 
           code.CodeCombo12, 
           code.CodeCombo13, 
           code.CodeCombo14, 
           code.CodeCombo15, 
           code.CodeCombo16, 
           code.CodeCombo17, 
           code.CodeCombo18, 
           code.CodeCombo19, 
           code.CodeCombo20, 
           code.CodeCombo21, 
           code.CodeCombo22, 
           code.CodeCombo23, 
           code.CodeCombo24, 
           code.CodeCombo25, 
           code.CodeCombo26, 
           code.CodeCombo27, 
           code.CodeCombo28, 
           code.CodeCombo29, 
           code.CodeCombo30 
          }, 
          code.CodeText1, 
          code.CodeTextAbbreviation1, 
          code.CodeText2, 
          code.CodeTextAbbreviation2, 
          code.CodeText3, 
          code.CodeTextAbbreviation3, 
          code.CodeText4, 
          code.CodeTextAbbreviation4, 
          code.CodeText5, 
          code.CodeTextAbbreviation5, 
          code.CodeText6, 
          code.CodeTextAbbreviation6, 
          code.CodeText7, 
          code.CodeTextAbbreviation7, 
          code.CodeText8, 
          code.CodeTextAbbreviation8, 
          code.CodeText9, 
          code.CodeTextAbbreviation9, 
          code.CodeText10, 
          code.CodeTextAbbreviation10, 
          CodeInt = new { code.CodeInt1, code.CodeInt2, code.CodeInt3, code.CodeInt4, code.CodeInt5, code.CodeInt6, code.CodeInt7, code.CodeInt8, code.CodeInt9, code.CodeInt10 }, 
          CodeNum = new { code.CodeNum1, code.CodeNum2, code.CodeNum3, code.CodeNum4, code.CodeNum5, code.CodeNum6, code.CodeNum7, code.CodeNum8, code.CodeNum9, code.CodeNum10 }, 
          CodeBool = new 
          { 
           code.CodeBool1, 
           code.CodeBool2, 
           code.CodeBool3, 
           code.CodeBool4, 
           code.CodeBool5, 
           code.CodeBool6, 
           code.CodeBool7, 
           code.CodeBool8, 
           code.CodeBool9, 
           code.CodeBool10, 
           code.CodeBool11, 
           code.CodeBool12, 
           code.CodeBool13, 
           code.CodeBool14, 
           code.CodeBool15, 
           code.CodeBool16, 
           code.CodeBool17, 
           code.CodeBool18, 
           code.CodeBool19, 
           code.CodeBool20, 
           code.CodeBool21, 
           code.CodeBool22, 
           code.CodeBool23, 
           code.CodeBool24, 
           code.CodeBool25, 
           code.CodeBool26, 
           code.CodeBool27, 
           code.CodeBool28, 
           code.CodeBool29, 
           code.CodeBool30 
          }, 
          CodeMoney = new { code.CodeMoney1, code.CodeMoney2, code.CodeMoney3, code.CodeMoney4, code.CodeMoney5, code.CodeMoney6, code.CodeMoney7, code.CodeMoney8, code.CodeMoney9, code.CodeMoney10 }, 
          CodeDate = new { code.CodeDate1, code.CodeDate2, code.CodeDate3, code.CodeDate4, code.CodeDate5, code.CodeDate6, code.CodeDate7, code.CodeDate8, code.CodeDate9, code.CodeDate10 }, 
          CodeMemo = new { code.CodeMemo1, code.CodeMemo2, code.CodeMemo3, code.CodeMemo4, code.CodeMemo5, code.CodeMemo6, code.CodeMemo7, code.CodeMemo8, code.CodeMemo9, code.CodeMemo10 }, 
          code.CodeURL, 
          code.SessionVariable, 
          code.bMandatory, 
          code.PopUp, 
          code.bDrillDown, 
          code.Icon 
         }; 

는 다음과 같은 예외가 발생합니다 :

An unhandled exception of type 'System.StackOverflowException' occurred in EntityFramework.dll 

나는 그것에 대해 검색 한을하지만 난 내 쿼리가 정상적으로 작동 선택 알엇을 건너 뛸 때 내 경우는 다릅니다. 나는 이유를 모른다. 그러나 건너 뛰지 않고 예외를 던집니다.

도와주세요 ..

+0

죄송 합니다만,이 쿼리는 미친입니다. 이 단계를 더 진행하기 전에 데이터 모델을 표준화해야합니다. 그런 다음 UI의 여러 부분을 별도의 단계로 작성하십시오. 왜 모든 것을 하나의 유지할 수없는 단일체로 만드나요? –

+0

그 외에도,'StackOverflowException'은 코드를 실행할 수 없으면 찾아 내기 어렵습니다. 그러나 나는 생성하려고하는 SQL 코드의 양에서 LINQ-to-SQL 쵸크를 확신합니다. –

+0

@Gert Arnold 이것이 클라이언트의 요구 사항이라면? 나는 이것이 미친 짓이라는 것을 알고 있지만 어떻게 할 수 있을까. – user3253756

답변

0

많은 어려움을 겪은 후에 나 혼자 답을 찾았습니다.

db.ConvertLongKeyUDF (LongKey) replace with 
db.ConvertLongKeyUDF (LongKey) As ConvertedtLongKey 


CodeGroup.Notes replace with 
CodeGroup.Notes As codeGroupNotes 


CodeGroup.bProtected replace with 
CodeGroup.bProtected As codeGroup_bProtected 


code.Notes replace with 
codes.Notes As codeNotes 


code.bProtected replace with 
codes.bProtected As code_bProtected 

이 줄들은 ERROR!