What would be the simplest way to create a quick editor for some data in the database in WPF/WinForms, where the data is represented by a View in the SQL Server database?
Say I have a table Person { id int, name nvarchar(max), GenderID int, CityID int}
, where GenderID and CityID is a reference into tables Gender and City. In the editor, the Person would appear as textbox for name, combobox for gender (selecting names of the genders from Gender table) and the same for the city column.
Is there something easy that I can do so some control/code would generate this? If I'd like to only select data, then WinForms DataGridView or WPF DataGrid can generate a column for each property, and show a row for each object in a collection. -
Is there some kind of similar magic control, that could do this for a database view, if the relations are defined by a foreign key?
It seems to me that thousands of developers have faced this kind of problem - to quickly create a GUI for editing database rows with relationships to other tables, so there should be some kind of universally accepted solution. Or is everyone doing this in the code? Or, if there is a tool for this in other language, not C#, not Windows Forms - like dBase.
You are describing what is known as scaffolding in web development. Scaffolding is a way to automatically generate UIs for each table in the database. Scaffolding lets you create a functional UI for viewing and editing data based on the schema of the data. Here are a couple of resources for WPF scaffolding.
Enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With