Fazer uma PerguntaFazer uma Pergunta
 

RespondidoInclude while joining

  • quinta-feira, 2 de julho de 2009 14:06RobinBronsteede Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Contém Código
    Hi,

    I have a query like this
    using (AIR20_con context = new AIR20_con())
    {
            var result = from s in context.StudentSet.Include("Nat")
                              join v in context.VInsSet on s.RELATIE_ID equals v.RELATIE_ID
                               where (s.NAT.NATGBA != 1 && v.INS_JR == insJr)
                               select s;
    

    Do have a relationship, while VIns and Student have the same column (Relatie_id).

    In the result the table NAT is not included, while query like

    using (AIR20_con context = new AIR20_con())
                {
                    var result = from s in context.StudentSet.Include("Nat")
                                 where (s.Field != 1)
                                 select s;
    has no problem.

    Can I solve the problem, or should I create a work around? By the way, its an Oracle DB with DevArt dataprovider

    Robin

Respostas

  • quinta-feira, 2 de julho de 2009 17:53Kati Iceva - MSFTModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    Hi Robin

    This behavior is by design.

    If the query contains operation that changes the intermediate result type between the Include and the outer most operation, like the join operation does in your first query, the Include is ignored.

    You could rewrite the query in the following way to have to Include honored:

    var result = ((ObjectQuery<Student>)(

                   from s in context.StudentSet.Include("Nat")

                  join v in context.VInsSet on s.RELATIE_ID equals v.RELATIE_ID

                  where (s.NAT.NATGBA != 1 && v.INS_JR == insJr)

                  select s).Include(“Nat”);

    I hope that helps.

    Thanks,

    Kati


    This posting is provided "AS IS" with no warranties, and confers no rights.

Todas as Respostas

  • quinta-feira, 2 de julho de 2009 17:53Kati Iceva - MSFTModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    Hi Robin

    This behavior is by design.

    If the query contains operation that changes the intermediate result type between the Include and the outer most operation, like the join operation does in your first query, the Include is ignored.

    You could rewrite the query in the following way to have to Include honored:

    var result = ((ObjectQuery<Student>)(

                   from s in context.StudentSet.Include("Nat")

                  join v in context.VInsSet on s.RELATIE_ID equals v.RELATIE_ID

                  where (s.NAT.NATGBA != 1 && v.INS_JR == insJr)

                  select s).Include(“Nat”);

    I hope that helps.

    Thanks,

    Kati


    This posting is provided "AS IS" with no warranties, and confers no rights.
  • sexta-feira, 3 de julho de 2009 5:51RobinBronsteede Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Thanks Kati,

    This solves the problem

    Robin