와 기본 다음 코드는 .Single이나 조건 또는 조항
return
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.Where(cust => cust.Id == customerId && cust.CustomerType== (int)cusType)
.SingleOrDefault();
를 Where을 제거 다음과 같이 다시 작성 될 수에게 있습니다.
return
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.SingleOrDefault(cust => cust.Id == customerId && cust.CustomerType == (int)cusType);
어느 것이 더 나은 관행이고 왜 그런가? 예외가있을 경우, 이와
var temp = this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.Where(cust => cust.Id == customerId && cust.CustomerType == (int)cusType);
return temp.SingleOrDefault();
: 함수의 리턴 값을 디버깅의 복잡성 및 디버거에서 람다 식을 사용 불가능으로
생성 된 'SQL'쿼리가 동일하므로 사용자 의견이 더 좋다고 말할 수 있습니다. – MarcinJuraszek
두 번째는 짧고 여전히 읽기 쉽습니다. –
첫 번째 코드는 단계별 코드를 따르고 확장/디버그하기가 더 쉽다고 생각합니다. –