سؤال

I am using Simple.Data ORM to handle my DB operations. I am not sure how to handle the case of inserting One to many and many to many data.

Say for example I have a customer and order table and I want to save data with one customer and two orders. Should I wrap the 3 DB insert statement inside a transaction or does Simple.Data support some other way of handling parent child inserts?

Similarly how can I handle the same scenario in many to many case?

هل كانت مفيدة؟

المحلول

Currently Simple.Data does not support saving object graphs in one call so you need to Insert the parent, save it's ID, set it on all children objects and finally Insert all the children.

This might improve in Simple.Data v2, as you can read in this post by Mark Rendle, the author of Simple.Data (section Better WithStuff): http://blog.markrendle.net/2013/09/18/simple-data-2-0/ .

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top