开发者

Parent-Child relation while using object data source

I am experiencing with a class generator I'v开发者_开发知识库e written, which generates a class for each table in database with each table field as a property and such. Before that, I used to add a typed dataset to the project and add some tables to it. It automatically detected the relationship between tables and when I added a parent table as data source of a datagrid, I could add another datagrid and use the foreing key data member of it's bindingsource to fill it, and when someone moved the focus on parent datagrid, the data in child datagrid would change accordingly. Now that I have my classes, I add an object as data source for my 2 datagrids, but obviously it doesn't detect a parent child relation. But It'd really help if I could have that foreign key relation in my object datasources. Is there any way to have that relation in object datasource?


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

In case you use ADO.Net, there might be a chance you forgot to tick the choice "Include Foreign Key Columns in the Model." in the ADO wizard but no worries (we've all been there, tick boxes are notoriously easy to overlook ;) ), you'll simply have to re-generate the model (re-run the wizard) but be sure to copy-paste any custom code you've added to a text file or something, so you don't lose it. Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜