I am unable to convert sql query to lamba expression in entity framework core. below is the sql query -
select c.company_id,industry_id,company_name,city,count(first_name) "Count" from company c join employee e on c.Company_id = e.Company_id where c.Company_name in ('"15 Minutes" Inc.', '!mpactMEDIA','"Stuffed" Cajun Meat Market & Specialty Food Store' ) group by c.company_id,industry_id,Company_name,city
I need to select only few columns from both tables.
please help me on writing an lamba expression.
What I have tried:
I tried as below mentioned code its not working
_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.First_name.Count()
})
.Where(input => input.company == sb.ToString())
.GroupBy(c => new { c.companyID, c.industryType, c.company, c.location });
I am having entity(Search) which has companyID,industryType,company,location,contacts as members of entity. I am return the value of the linq query to IQuerayable<search>. I am getting error as cannot convert to IQuerayable<search> from IQueryable<Igrouping< anonymous>>>