I have a list of languages and I need to show how many users subscribe to each.
I work on my project with Angular 13 and AsP.net Core 6 and SQLServer but there are two blocked ways
Use angular services in NgFor but return infinite loops and crash.
Use .NET to return the list of languages and loop a second query to get count users but not work.
the last is to Create something with SQLSever ( I don't know how )
[
CodePudding user response:
In your API you will need to return a payload that you can use to show the results you expect. From the API layer, you need to access the database and transform data to the meet the former challenge. The query to obtain the results is rather straightforward.
SELECT
L.lang_id,
L.title,
L.description,
L.image,
COUNT(*) as UserCount
FROM
Languages L
INNER JOIN Users U on U._id_lang = L.id_lang
GROUP BY
L.id_lang