ASP.NET CORE 6.0计数

发布于 2025-02-12 00:39:16 字数 503 浏览 0 评论 0原文

干草 我正在研究我在C#和ASP.NET Core 6.0考试的项目中,老师希望我数数参加比赛的每个注册。

(几乎没有更多信息;它的巡回训练网站和数据库都有2个桌子。锦标赛和注册。因此,他们希望我数量与桌子中的每个注册一起注册与同一toramentallentiD的注册。)

我不知道该怎么做,好吧,我知道我需要使用计数方法。

我的TOUGHTS:

计数列表_context.tournament.tournamentId == _context.Signups.touramentiond

我不知道如何将其放入代码中。有人可以帮我吗?

**编辑1:

顺便说一句,这是我尝试过的代码,但它不起作用。

var count = _context.Signups.Count(t => t.TournamentId == id);
            ViewBag.CountingSingups = count;

Hay
Im working on a project for my exam in C# and ASP.NET Core 6.0 , the teachers want me to count every sign up on a tournament.

(little more information; Its a tournement website and the database has 2 tables for this. Tournament and Sign Ups. So they want me to count every sign up in the table Sign Ups with the same TournamentID.)

I dont know how to do this, well i know that i need to use a Count method.

My toughts:

Count list where _context.Tournament.TournamentID == _context.SignUps.TournamentID

I dont know how to put this in a code. Can someone help me?

**Edit 1:

Btw, this is a code i tried, but it dont work.

var count = _context.Signups.Count(t => t.TournamentId == id);
            ViewBag.CountingSingups = count;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一袭水袖舞倾城 2025-02-19 00:39:16

通过遵循此条件,您将分别获得每个比赛的注册计数。

var count = _context.Signups.GroupBy(gp => gp.TournamentID ).Select(y => new
                {
                    TournamentID = y.Key,
                    CoutOfusers=y.Count()
                 }).ToList();

By following this condition you will get count of Signups for each tournament individually.

var count = _context.Signups.GroupBy(gp => gp.TournamentID ).Select(y => new
                {
                    TournamentID = y.Key,
                    CoutOfusers=y.Count()
                 }).ToList();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文