linq2sql을 엔티티 프레임 워크로 변환 중입니다.Entity Framework 4로드가 전혀 작동하지 않습니다!
변환 중에 linq2sql의 loadwith를 eagar 로딩을 위해 include로 변환해야했지만 열정적 인 로딩이 작동하지 않습니다. 프로파일 러를 사용할 때 하위 엔티티가 액세스 된 상태에서로드되었음을 발견했습니다.
DataBaseEntities context = new V3C_DataBaseEntities();
context.Agents.Include("Account");
Agent ag = context.Agents.Where(x => x.Login_ID == "2").SingleOrDefault();
// here the account should have been loaded,
// but actually they are loaded with the line below this is executed.
Console.WriteLine(ag.Account.ID.ToString());
다음 작업을 수행하면 완벽하게 작동하지만 질문에서 언급 한 방법대로 수행해야합니다.
var c = (from ag in context.Agents.Include("Account")
where ag.Login_ID == "2"
select ag).SingleOrDefault();
하위 엔티티를로드 할 때 유형이 안전한 방법을 원합니다. 당신은 내가 당신이 원하는 결과를 얻을 것으로 예상 식 내에서 Include
를 배치 할 쿼리를 변경하는 경우
context.Agents.Include("Account");
Agent ag = context.Agents.Where(x => x.Login_ID == "2").SingleOrDefault();
:
안녕하세요, 내가 잘 작동하고 있다고 말했지만, 나는 아주 큰 방법이 있고 그 방법의 datacontext가 매개 변수에 따라로드되기 때문에 다른 방식으로해야합니다. 결론은, 내가 질문에 정의 된대로 datacontext를로드해야합니다. –
두 번째로, linq2sql을 엔티티 프레임 워크에서 가장 매끄러운 방식으로 변환하고 싶습니다. –