开发者

One to Many Insert statement in Linq

开发者 https://www.devze.com 2023-03-30 17:27 出处:网络
Hi I know this type of question is already asked on SO. But I havent get satisfied. So i am posting my own scenario.

Hi I know this type of question is already asked on SO. But I havent get satisfied. So i am posting my own scenario. I have form with 2-3 textboxes and a checkedboxlist. There 1 to many relationship, so to maintain it i have two different tables on for holding the text box values and another holds the Identity of above with the multiple checkbox values. Refer the image below

One to Many Insert statement in Linq

I have 3 tables for that out of which two are used for CRUD operation. Category table is used for binding the checkedboxlist control whereas the Listing and CategoryListing Map are the tables populated from the form shown above.

One to Many Insert statement in Linq

When save button will clicked, First three textbox values will go to Listong table and the identity will then paired up with the selected checkbox from the li开发者_开发百科st control and save to map table. This is what i need.

Please help me.

Pls Note : I am using Linq2Sql, there is no user defined POCO, the entity class used is generated by the dbml itself.


Basically you'll need to create a new Listing object and a new CategoryListingMap, which will have listing = the Listing object you created and categoryid = the id selected. On saving the CategoryListingMap, you should have a new Listing entry in db as well.

0

精彩评论

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

关注公众号