Search code examples
c#algorithmlistinsertdynamic-arrays

How to generate dynamic multi-dimensional list or array and insert data accordingly based on a dynamic SQL Server table in c#?


I want to create a dynamic 2-dimensional array (or any other structure) based on a dynamic database table in C# or T-SQL, which means the data source (which is a database table) is dynamic too.

EDIT:

Table structure:

enter image description here

For example:

If User1 meets the condition of Admin and Group1, it will be inserted into (Admin, Group1). And the users are constantly added in with different user type and group. So, every cellular can have as many as users.

And the problem is I don't know how many user types and groups there are, because new user types and new groups are added constantly too.

enter image description here

For now, I think I need to parse every data to find if it meets the existing conditions. If yes, insert it into the specific condition; if not, create a new condition and insert data into it.

But I don't have any idea about how to implement it? Do you have any ideas or algorithms?

Thanks very much for any suggestion or information.


Solution

  • I've solved this statically with Tuple, but not dynamically. I think I should re-fresh my tuple list periodically. But at least, it works now!

    Any suggestions are welcome! Thanks!