Version 13.4.0, Angular 18, .NET 8
Hi support,
Is there an easy way to query AbpNotificationSubscriptions table? I was trying to find the AbpNotificationSubscriptions entity class so that to inject with IRepository but couldn't find it.
Unfortunately the INotificationSubscriptionManager is not the case as there is not any function that returns what we want.
Thanks, Loizos
2 Answer(s)
-
0
Hi @Loizos
The
AbpNotificationSubscriptionstable is not exposed via a standardIRepository, so you cannot directly inject a repository for it. Instead, the ABP framework provides services to work with notification definitions and subscriptions.If you need to access notification subscription data, you should use the following:
INotificationDefinitionManagerlets you query available notification definitions. For example, you can check if a notification is defined, list definitions, etc.INotificationStoregives you direct access to subscription and notification entities (includingNotificationSubscriptionInfo). You can use methods like:GetSubscriptionsAsync(...)InsertUserNotificationAsync(...)IsSubscribedAsync(...)
Example usage:
public class MyNotificationAppService : ApplicationService { private readonly INotificationStore _notificationStore; private readonly INotificationDefinitionManager _notificationDefinitionManager; public MyNotificationAppService( INotificationStore notificationStore, INotificationDefinitionManager notificationDefinitionManager) { _notificationStore = notificationStore; _notificationDefinitionManager = notificationDefinitionManager; } public async Task<List<NotificationSubscriptionInfo>> GetUserSubscriptions(long userId) { return await _notificationStore.GetSubscriptionsAsync(new UserIdentifier { TenantId = AbpSession.TenantId, UserId = userId } ); } }This way you don’t need to query the table directly the framework provides abstractions for it.
If you specifically need raw access to the subscription records, you can still fall back to
DbContext.Set<NotificationSubscriptionInfo>(), but the recommended approach is to useINotificationStoresince it encapsulates the logic for working with theAbpNotificationSubscriptionstable.Related Source Code (INotificationStore)
Related Source Code (INotificationDefinitionManager)
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @oguzhanagir
Thank you for your fast response on this!
Yes I was looking for NotificationSubscriptionInfo so that to inject it in my class and be able to query the table directly so thanks for all the information, I found what I wanted within your suggested source code (NotificationStore class).
Basically both INotificationStore and INotificationDefinitionManager do not work for me as I cannot get back a list of all entity type subscriptions because the EntityId is included in predicate, so I just needed to build custom query.
Issue solved thanks for help again!
Regards, Loizos
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)