I have a table in the DB with two columns, roles and permissions that looks like this:
role – permission
user – addItem
admin – removeItem
admin – advancedSearch
guest – simpleSearch
user – editItem
manager – editUser
…etc.
I need to store these in the .net’s cache so that I can check if a permission exists for a specific role.
(Here’s the psuedo-code)
if ("permission" is in Cache["role"]) // Authorize access
But how do I add and store them in the Cache for best result?
In PHP I’d do something like this I guess:
array ( "user" => array ( "addItem", "editItem"),
"admin" => array ( "removeItem", "advancedSearch"),
....
Is there an equivalent or better/faster way in C#?
Thanks!
/Niklas
Maybe something like a
Dictionary<string, HashSet<string>>?For example:
Or if reading from a data-reader (comment):