views:

34

answers:

1

hi, someone can tell me how to do this query in EF1: select a.idAnimali, a.titolo, a.commenti, a.ordine, a.idcatanimali, table1.nomefoto FROM tabanimali as a LEFT JOIN (SELECT idanimali, nomefoto tabfotoanimali FROM LIMIT 1) AS Table1 On a.idAnimali = table1.idanimali WHERE a.idcatanimali = idcatanimale

Thanks

A: 

Let me know if this works for you, i think what u posed has a typo and i am assuming tabfotoanumali is your second table.

  var query = (from a in tabanimali
    join p in tabfotoanimali.FirstOrDefault() on a.idanimali equals p.idanimali 
    where a.idcatanimali = idcatanimale
    select new {
             a.idAnimali, 
             a.titolo, 
             a.commenti, 
             a.ordine, 
             a.idcatanimali,
             p.nomefoto
     }
  );
Nix
Thanks for reply, but does not work gives me the following error:"The type of an expression in the join clause is incorrect. Type Inference failed in call to 'Join'Then, I wanted to tell you that in your expression, I have not seen the LEFT JOIN.and I heard that EF1 does not accept the clause DefaultIfEmpty.So I tried to create the following expression: var query = (from a in mareblu.tabanimali.Include("tabfotoanimali")let topfoto a.tabfotoanimali.Select = (x =>x.nomefoto).Take (1)select new(ida=a.idAnimali,photo=topfoto));However, even this will not work. tabfotoanimali is my second table