开发者

How should I store this information?

开发者 https://www.devze.com 2022-12-29 19:22 出处:网络
I have a PrivilegeGroup table, a Privileges table and a link table because the PrivilegeGroup table and the Privileges table is a many to many relationship. I am thinking about load all contents of Pr

I have a PrivilegeGroup table, a Privileges table and a link table because the PrivilegeGroup table and the Privileges table is a many to many relationship. I am thinking about load all contents of PrivilegeGroup table and Privilege table into memory from data开发者_如何学Pythonbase at beginning when application started.

I want to save them in a form easily to look up. Usually we will look up the PrivilegeCode via GroupId.

Which structure is good for this purpose? array of list? dictionary?


It sounds like you want to be able to look up PrivelegeCode by the GroupId and don't need any other data? If that is the case then you could use a Dictionary<GroupIdDataType, PrivelegeCodeDataType> which should make the lookups easy.

As for loading them all at once on starting the application, I guess it just depends on if changes to this data while the application is running should have any effect on the program without having to restart it.


How about

Dictionary<GroupIdType, HashSet<PrivilegeCodeType>>

This way you can quickly get the HashSet of privileges by GroupId, and do a quick test against the HashSet to check if the privilege exists.


I'll suggest you to keep the data in the instance of DataTable class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号