Issue
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 SQL Server 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 SQL Server (I don't know how)
[
Solution
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
Answered By - Ross Bush
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.