I want to SELECT all the data from a particular table by adding a countField to the results that counts the number of times that the corresponding Item.ResourceId exists in all the results.
SELECT Name, ResourceId, (SELECT COUNT(ResourceId) FROM Item GROUP BY ResourceId) AS foo
FROM Item
Any ideas on how to do this?
If this is your desired query
it translates to LINQ as follows.
Or do you want this query?
This translates to the following LINQ expression.
Given the following input
the first query yields
while the second query yields this.