Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a query in linq but i want into method syntax of this query
var q = (from account in Accounts
         join student in StudenTables
         on account.Alias equals student.stdID
         join cour in Course on student.stdID.Substring(2, 3) equals cour.CourseCode
         select new
         {
             account.Alias,
             cour.CName,
             student.stdName,
             student.stdFather,
             account.AccountId
         }).ToList();

so how can i convert this query. anyone tell me.
Posted
Comments
Maciej Los 27-Feb-15 14:23pm    
What you mean by saying: convert Linq to method?
J{0}Y 28-Feb-15 1:19am    
like this dcdc.registrations.Where(A => A.RegId == int.Parse(txtRegId.Text)).Single()
Maciej Los 1-Mar-15 6:37am    
Not clear ;(
Please, be more specific and provide more details. We can't read in your mind or direct from your screen...

1 solution

C#
var query =
               Accounts.Join(StudenTables,
               a => new { a.Alias },
               s => new { Alias = s.stdID },
               (a, s) => new { a, s }).
               Join(Courses,
               x => new { CourseCode = x.s.stdID.Substring(2, 3) },
               c => new { c.CourseCode },
              (x, c) => new { x.a.Alias,
                              c.CName,
                              x.s.stdName,
                              x.s.stdFather,
                              x.a.AccountId }).ToList();
 
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