Parent-child relationship when using an object data source

I came across a class generator I wrote that generates a class for every table in the database, with every table field being a property, etc. Before that, I was adding a typed dataset to the project and adding multiple tables to it. It automatically detected the relationship between the tables, and when I added the parent table as the datagrid data source, I could add another datagrid and use the bindingsource for that key data item from it, and when someone moved focus to the parent datagrid, the data in the child datagrid have changed accordingly. Now that I have my classes, I add an object as a datasource for my two data, but obviously it doesn't detect the parent child relationship. But it would really help,if I had this foreign key relationship in my object datasources. Is there a way to have this relationship in the datasource?

+2


a source to share


1 answer


If you are using LINQ ORM, your foreign key relationship is automatically reflected in your generated model. Take a look at http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx for more information.



If you are using ADO.Net, you may have forgotten to check the "Include foreign key columns in model" checkbox. in the ADO wizard, but don't worry (we were all there, checkmarks are notoriously easy to miss;)), you just need to re-create the model (re-run the wizard), but be sure to copy - paste any custom code added to the text file or something like that so you don't lose it. Good luck!

0


a source







All Articles