Getting Values from EF Core Context with Dynamic Calls to Tables.

Copper Contributor

I'm working in EF Core 5 with Razor pages connecting to SQL Server and am trying to develop a generic form that handles multiple lookup tables. So I'm trying to dynamically access the tables in my context. My problem is that I can access the Properties (column names) of the tables themselves but I can't access the keys of the IEnumerable object when I pass it. I have a dictionary of all the tables that passes the context to the form. I can see the data is there along with the keys. How do I reach the keys (specifically CenterTypeId and CenterType in the images provided) so I can get my data without having to pass a select in my context dictionary? Some of the tables I'm going to be using have more than 2 columns and I'll need access to all the data in them. The only properties in the dbSet IEnumerable variable that I am able to access are the Entity Type and the Tracking.LocalViewFull Code ViewFull Code ViewTable information and Results Views.Table information and Results Views.

1 Reply

Hi @Rozemyne,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang