C
C#2y ago
scorch

❔ SQL Table to Object

I have a SQL Table "Card" with a column "CardNr" and a column "CardType". How would I make this in to an object of my Card class?
4 Replies
Angius
Angius2y ago
Depends what you want to use ADO? You'll need to wrestle with the reader, convert the values, all sorts of songs and dances Dapper? Just execute the query and pass the class as a generic parameter EF Core? Hopefully you're using code-first design, but if not... well I never used database-first design, but I guess you could just scaffold the code and use regular EF queries
Anton
Anton2y ago
If you're using Visual Studio, there's an EF Core extension for database-first EF Core power tools I've seen it recommended a lot
rhymbit
rhymbit2y ago
There's also a class called DataTable in C#. You can check it out as well https://learn.microsoft.com/en-us/dotnet/api/system.data.datatable?view=net-8.0
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server