2009-05-29 4 views
2

선택 배수 테이블 :Ado.Net 엔티티 프레임 워크, LINQ : 나는 테이블 DetalleContenido 및 기록 보관소에서 데이터를 검색하는 C#에서이 문장을 사용

DataBase Model http://img9.imageshack.us/img9/4230/modelodatos.png

:

var detallesContenido = 
    from contenido in guiaContext.Contenido 
     where contenido.PuntoInteres.id_punto == puntoInteresID 
    from dc in contenido.DetalleContenido 
     where dc.Idioma.ds_idioma == idiomaCliente 
    select dc; 

테이블 사이의 관계는 이것이다

나는 puntoInteresID와 idiomaCliente를 사용하여 PalletoIntres의 일부인 DetalleContenido와 Archivo에서 모든 행을 검색하지만이 문장은 Archivo가 항상 null입니다!

는 SQL sentece 등가입니다

Select dc.ds_nomDetContenido, dc.ds_descDetContenido, ar.archivo 
from Contenido c, DetalleContenido dc, Archivo ar, Idioma i 
where c.id_punto = puntoInteresID 
    and c.id_contenido = dc.id_contenido 
    and dc.id_idioma = i.id_idioma 
    and i.ds_idioma = idiomaCliente 
    and dc.id_archivo = ar.id_archivo; 

어떻게 너무 기록 보관소를 검색 할 수 있습니다?

감사합니다.

답변

1

처럼 보일 것 같아.

귀하의 질문에 대한 귀하의 Archivo 테이블은 1 대 다수이고 당신은 equasion의 "많은"면을 "포함"하거나 "로드"할 수 없습니다. "dc.Archivo 선택"을해야 할 것입니다.

+0

당신 말이 맞아요. select new {dc, dc.Archivo}를 사용하여 Archivo 테이블을 얻습니다. – VansFannel

0

Include() 문을 사용해 보셨습니까? (당신이 그들을 사용하는 경우) 나는 또한 선택한 개체의 "참조"properity에

.Load() 

을 할 수있는가이

var detallesContenido = 
     from contenido in guiaContext.Contenido.Include("DetalleContenido") 
      where contenido.PuntoInteres.id_punto == puntoInteresID 
     from dc in contenido.DetalleContenido 
      where dc.Idioma.ds_idioma == idiomaCliente 
     select dc; 
+0

예, 가능하지만 작동하지 않습니다. – VansFannel

0

대해 어떻게 :

var detallesContenido = 
    from contenido in guiaContext.Contenido 
     where contenido.PuntoInteres.id_punto == puntoInteresID && contenido.DetalleContenido.Any(c=>c.Idioma.ds_idioma == idiomaCliente) 
    select contenido.DetalleContenido; 
+0

DetalleContenido와 Archivo를 검색하고 싶습니다. – VansFannel

0

내 솔루션이 있습니다 :

var detallesContenido = 
    from contenido in guiaContext.Contenido 
     where contenido.PuntoInteres.id_punto == puntoInteresID 
    from detalleContenido in contenido.DetalleContenido 
     where detalleContenido.Idioma.ds_idioma == idiomaCliente 
    select new { detalleContenido, detalleContenido.Archivo }; 

감사합니다!