2009-08-27 2 views
0

분리 된 쿼리 :Linq를하려면 NHibernate에 - 나는 다음과 같은 상황에있어

 var totalRecords = (from entry in invalidAccEntryRepository 
          select entry).Where(entry => 
           entry.CustomerAccountInfo.CustomerAccountName == CustomerAccountName && 
           entry.CustomerAccountInfo.CustomerAccountId == CustomerAccountId).Count(); 

 var totalRecords = (from entry in invalidAccEntryRepository 
          select entry); 

     if (CustomerAccountInfoFilterActive) 
     { 
      totalRecords.Where(entry => 
           entry.CustomerAccountInfo.CustomerAccountName == CustomerAccountName && 
           entry.CustomerAccountInfo.CustomerAccountId == CustomerAccountId); 
     } 

     totalRecordsCount = totalRecords.Count(); 

첫 번째 쿼리가 완전하게 작동하지만 두 번째 쿼리는 유일한

var totalRecords = (from entry in invalidAccEntryRepository 
          select entry); 
을 실행을

을 조건부로 추가 한 표현식을 무시합니다.

누구든지 문제가 무엇인지 알 수 있습니까? 더 많은 정보가 필요하십니까?

미리 Thx!

답변

1

실제로 어디에 적용하지 않습니다. if에서 대신 다음을 사용하십시오.

totalRecords = totalRecords.Where(entry => 
           entry.CustomerAccountInfo.CustomerAccountName == CustomerAccountName && 
           entry.CustomerAccountInfo.CustomerAccountId == CustomerAccountId); 
+0

고마워요! – Chris

+0

Chris는 문제 없습니다. :) –