Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, in this query, ther are 2 tables t007 and t017 in join right join.
This code work well.

var res = (
 from A in CurrentDbContext.t007
 join B in CurrentDbContext.t017 on A.id_soc equals B.id_soc into JOIN_AB
 select new
     {
         Id_soc_rappr = A.id_soc_rappr,
         Person_G = JOIN_AB  //in this case I see all columns
     }
        ).ToList();

But I want show only 2 columns and not all columns about second table.

What I have tried:

I try this code, but doesn't work. How can I resolve ?
select new
             {
                 Id_soc_rappr = A.id_soc_rappr,
                 Person_G = JOIN_AB.id_person  //in this case I want a single colum
             }
Posted
Updated 5-Oct-21 2:34am

1 solution

JOIN_AB is a list of records from your t017 table. It doesn't have a property called id_person.

Try projecting the list to select just the column(s) you want:
C#
select new
{
    Id_soc_rppr = A.id_soc_rappr,
    Person_G = JOIN_AB.Select(b => new { b.id_person })
}
 
Share this answer
 
Comments
antobaro 5-Oct-21 8:48am    
Great !!!! Very many Thanks !!!! ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900