I am used to repo -> service -> controller MVC models, and I do not have much experience with in-memory retrieval beyond using LinQ.
Say I have a class which could have multiple queryable fields:
public string SignalRId { get; set; } public int UserId { get; set; } public string Nickname { get; set; } public string Region { get; set; } public string RoomName { get; set; }
public string SignalRId { get; set; } public int UserId { get; set; } public string Nickname { get; set; } public string Region { get; set; } public string RoomName { get; set; }
In a normal appcontextdb access scenario, I would just pull out the values using EFCore LinQ using something like
var user = await _context.Users.FirstOrDefaultAsync(u => u.UserId == UserId)
var user = await _context.Users.FirstOrDefaultAsync(u => u.UserId == UserId)
In my SignalR Hub, I am using an in-memory method and not SQL to store my data since I don't expect users to have long-lasting data (unlikely they will maintain a connection for >5minutes per session). Therefore I inject a
ConnectedClientsService
ConnectedClientsService
and don't have a DB table.
- Is using
FirstOrDefaultAsync
FirstOrDefaultAsync
with regular IQueryable is more standard practice in this case (for example, searching for strings matching region, etc)? - Is it standard practice to use 2 concurrent dictionaries with a lock to enable O(1) access?