Using FormView for a LINQ entity that also has child entitiset to be updated too on any form operation
My basic linq entity that I want to update using FormView is 'Job' and I can simply add a FormView to operate all its CRUD operations. However, there is another entity 'JobExpertise' as child to this 'Job' entity, in Job(1)-JobExpertise(n) Relationship. I also want to operate on this JobExpertise as child rows on the same form.
So when any 开发者_JAVA技巧FormView action (i.e. Insert/Update/Delete) is performed. Job is modified along with related JobExpertise.
How to do it? I'm using .NET 3.5
in your scenario if it was me doing it i would have the Job on one Form View and then a DataGrid that is the list of the JobExpertises and a Another FormView for the item selected in the Data Grid.
To Add a JobExpertise you simply Add it to the Entity Collection of JobExpertise on the Job object, and when you add to the Model and SubmitChanges or Save Changes it will add this entity to your job Entity.
The same thing should happen with Updates and Delete.
Hope this is of some help.
精彩评论