I have several tables on SQL Server and an asp/c# website connected to it. I need to create a way to perform view/insert/update/delete functions on those tables through that website, otherwise i deal with red tape.
I don't think writing a class per table would be the most efficient way of doing this, and I don't know if number of tables will grow in the future. Besides, all of the present methods allow manipulating only one row through a different "update" page, which is inefficient given large amounts of data.
I found an article on dynamic templates here, and it seems like a good way to go, considering that our infrastructure is still on VS2005 with an upgrade option to 2008. http://aspalliance.开发者_开发百科com/1125_Dynamically_Templated_GridView_with_Edit_Delete_and_Insert_Options.all
Does anyone have other/better methods of managing database tables through C# based web site?
Generally speaking, pretty much any CRUD operation except reading is done one row at a time at the low level. There are bulk insert tools that allow uploading of large amounts of data without needing to wrap the data in SQL and then have the server parse it all back out, but that's basically the best you can do.
That said, class-per-table is absolutely the best practice for individual records. If you need access to bulk inserts, you may provide for upload of tab-delimited files through a web service or just using form submission.
You can simplify the page creation process using a generic base template webform that is extended by other webforms that nail down specifics. Depending on your UI needs and your domain, you may be able to design an interface where the child pages only need to specify the type of object they show data for.
You can use Dynamic Data approach with Linq to SQL
You can use,
- ASP.NET Dynamic Data Entities Web Application
OR
- ASP.NET Dynamic Data Linq to SQL Web Application
http://msdn.microsoft.com/en-us/library/cc488469.aspx
精彩评论