Click here to Skip to main content
15,796,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Can anyone please tell me hoe to join single table with self. I tried
db.DTOPageSets.Join(db.DTOPageSets, a => a.ContentPageID, b => b.CategoryID, (a, b) => a);

but getting error
Cannot implicitly convert type 'System.Linq.IQueryable<MVCCMSforALONSO.Models.DTOPageSet>' to 'System.Collections.Generic.List<MVCCMSforALONSO.Models.DTOPageSet>'. An explicit conversion exists (are you missing a cast?)

Please help....
Jameel VM 13-Sep-13 11:14am    
Please post the full code
Neema Derakhshan 14-Sep-13 2:54am    
what's db refers to ? DataClassesDataContext ? or DataBase ?
amolpatil2243 16-Sep-13 6:32am    
amolpatil2243 16-Sep-13 6:32am    
its a datacontext.

As you don't provide your full code here so it is difficult to help you,but following links would definitely help you:
Linq to SQL lambda join[^]
Simple Examples of joining 2 and 3 table using lambda expression[^]
Expressions and Self Join With Lambda in C#[^]
Share this answer
I used this and didn't get any error
db.DTOPageSets.Join(db.DTOPageSets.AsEnumerable(), a => a.ContentPageID, b => b.CategoryID, (a, b) => a);

hope it helps
Share this answer

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