I’m still feeling new to LINQ to SQL and need a pointer on the following.
I have this existing code in my controller which is used in my index view:
var allIncident = _securityRepository.FindAllIncident(userId, SystemType.EI);
var searchResults = (from s in allIncident
where s.IncidentDescription.Contains(searchText) &&
s.Site.SiteDescription.Contains(searchTextSite)
&& (s.Entered >= startDate && s.Entered <= endDate)
orderby s.Entered descending
select s);
This is fine, but I need to add another dynamic column (three actually, but once I know how it’s cool). I have a 1-M table called IncidentAction. There are many incident actions to one Incident. So I want to add an extra column that’s dynamic that will count the number of Incident Actions for each row in search results.
Where do I start? In SQL I’d just do a select count as col_name, but here I’m not sure where it goes.
Is this what you want?