How to create a C# class whose attributes are rows in a database table with ADO.NET?

家住魔仙堡 提交于 2019-12-30 11:20:17

问题


Is it possible?

Please note I am not using LINQ nor Entity Framework.


回答1:


You could also check out Dapper-Dot-Net - a very lightweight and very capable "micro ORM" which - incidentally - is used to run this site here.

It's quite fast, a single *.cs file, works with your usual T-SQL commands and returns objects - works like a charm, it's very fast, very easy to understand, no big overhead - just use it and enjoy!




回答2:


My personal favorite is done using the dynamic object featured in .NET4 via Rob Conery's Massive library. Like Dapper-Dot-Net it is small.




回答3:


By going old school you can use Datasets to create strongly typed data table classes that mirror your database entirely right down to the relationships. It's a precursor to LINQ/EF that auto-generates a lot of bloated code but they're very handy for maintaining your field names, data types, data constraints and performing easily configured rapid updates.

http://msdn.microsoft.com/en-us/library/esbykkzb(v=VS.100).aspx



来源:https://stackoverflow.com/questions/7346910/how-to-create-a-c-sharp-class-whose-attributes-are-rows-in-a-database-table-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!