C
C#11mo ago
_vegabyte_

Trying to create a notification service

Hi, I'm trying to create a notification service. My initial setup is I create a command that counts based on the query from where my data is. But the problem is the condition for the query is getting complicated and everytime there is a new condition to the query I need to update the Notification Service. Is there any way to simplified the Notification Services. Any suggestions and advice are well much appreciated. Thank you
No description
2 Replies
Angius
Angius11mo ago
I'm not sure how the query would be changing? You have a Notifications table with... notifications There's an FK to the user for whom the notification is And maybe a IsRead bool
var count = await _ctx.Notifications
.Where(n => n.UserId == id)
.Where(n => n.IsRead == false)
.CountAsync();
var count = await _ctx.Notifications
.Where(n => n.UserId == id)
.Where(n => n.IsRead == false)
.CountAsync();
Omnissiah
Omnissiah11mo ago
usually the way to simplify stuff is extracting/isolating (a part of) the logic 🤷‍♂️
Want results from more Discord servers?
Add your server