Ah. I did not know what _context was and I was not aware you were using EF. I assumed _context was some kind of property bag or class you controlled. So, the answer is no you would not have a UsersByToken property on your DbContext and it would not map to the database. Instead it should be a local field/property in your login class. Now that I understand you are making round trips to the database, you will find IDictionary<> to be even more efficient than your current code, but you will need a fall back to retrieving the user from the database if it is not found associated the provided token in your dictionary.
Ah. I did not know what
_context
was and I was not aware you were using EF. I assumed_context
was some kind of property bag or class you controlled. So, the answer is no you would not have aUsersByToken
property on yourDbContext
and it would not map to the database. Instead it should be a local field/property in your login class. Now that I understand you are making round trips to the database, you will findIDictionary<>
to be even more efficient than your current code, but you will need a fall back to retrieving the user from the database if it is not found associated the provided token in your dictionary.Thank you for this. Seems like IDictionary and IQueryable are my best bet for getting the most out of EF