엔티티에 linq를 잘 수행하는 데 문제가 있습니다. 내가 가진 쿼리 (내 코드가 아닌 다른 사람 코드 유지 :-))에는이 쿼리의 결과를 사용하는 WPF 화면에 필요한 모든 항목이 포함되어 있습니다.Linq to Entities 많은 컬럼에서 성능 문제가 발생했습니다.
이제 생성 된 SQL은 매우 빠르게 실행되고 한 행의 데이터 만 반환합니다. 하지만 그것은 570 열을 반환하고, 나는 모든 개체와 모든 필드를 만드는 오버 헤드에 성능이 있다고 생각합니다.
지연로드를 사용해 보았지만 성능에 아무런 영향을 미치지 않습니다.
필자는 불필요한 "include"문을 제거하려고 시도했지만 모두 필요하다고 생각됩니다. 여기
는 LINQ 쿼리입니다 :var myQuery =
from appt in ctx.Appointments
.Include("ScheduleColumnProfile")
.Include("EncounterReason")
.Include("Visit")
.Include("Visit.Patient")
.Include("Visit.Patient.PatientInsurances")
.Include("Visit.Patient.PatientInsurances.InsuranceType")
.Include("Visit.Patient.PatientInsurances.InsuranceCarrier")
.Include("MasterLookup")
.Include("User1")
.Include("User2")
.Include("Site")
.Include("Visit.Patient_CoPay")
.Include("Visit.Patient_CoPay.User")
.Include("Visit.VisitInstructions.InstructionSheet")
where appt.VisitId == visitId
&& appt.MasterLookup.LookupDescription.ToUpper() != Rescheduled
&& appt.Site.PracticeID == practiceId
&& appt.MasterLookup.LookupDescription.ToUpper() != Cancelled
orderby appt.AppointmentId descending
select appt;
는 SQL은 570 선택 한 Statment의 열 및 3 또는 4 연합 ALLS 4000 선 길이 생성, 그래서 나는 정말 누군가가 여기에 붙여 넣기하지 않을거야 그것을보고 싶어. 기본적으로 가능한 경우 노동 조합을 제거 할 수있는 방법을 찾고 있으며 필요한 부분 만 열을 정리합니다.
도움말!
:-)
: http://stackoverflow.com/questions/5521749/how-many-include-i-can-use-on-objectset-in-entityframework-to-retain-performance/5522195#5522195 –
감사합니다. 사용법이 미치는 영향을 설명하는 데 도움이됩니다. 포함. 그러면 솔루션은 objectContext.LoadProperty()를 사용합니까? – Scot
이 솔루션은 여러 기술을 사용하여 시나리오에서 최상의 성능을 제공하는 것입니다. –