开发者

WCF RIA Services Insert Child Items along with New Parent Item

开发者 https://www.devze.com 2023-03-29 01:37 出处:网络
Say I have a object called project, and each project has tasks... Lets say I wanted to create a project and specify tasks...Do all this in one form...and when the user clicks \'save\', save the projec

Say I have a object called project, and each project has tasks... Lets say I wanted to create a project and specify tasks...Do all this in one form...and when the user clicks 'save', save the project and tasks...However because project does not exi开发者_开发知识库st, when I create the tasks, they won't have a pk? How Can I handle this...be able to insert child with new parent...

Thanks,

Malcom


With Linq:

Project project = new Project();
project.Tasks = tasks;
db.SubmitChanges();

Linq will assign the primary keys and foreign keys.

0

精彩评论

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

关注公众号