srinath

srinath

  • NA
  • 144
  • 0

Using lambda unable to do join, groupby and where in EF Core

Jul 11 2018 8:03 AM
Hi,

I am trying to do join, group by and where condition using lambda expression in entity frame core but unable to return the query as IQuerayable. Below is the code -

await _entities.Company.Join(_entities.Employee,      
                        com => com.Company_id,   
                        emp => emp.Company_id,   
                        (com, emp) => new SearchCompany    
                        {                              
                          companyID = com.Company_id,  
                          industryType = com.industry_id,    
                          company = com.Company_name,      
                          location = com.City,    
                          contacts = emp.Employee_phone        
                         })                             
                      .Where(input => input.company == companyName)
                    .GroupBy(c => new { c.companyID, c.industryType, c.company, c.location })  
                     .ToListAsync();


SearchCompany is a class with companyID,industryType,company,location,contacts as string properties and I need to return these values.

Please help me in getting it solved. Thanks in advance.

Answers (3)