iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I am trying to add an item and some childs with one submit, but this does lead to an error.
What ist the regular way to add childs and child of child? An example would be nice.
this.Item = this.Repository.Create();
this.Repository.Insert(this.Item);
this.Item.Childs.Add(new Child());
this.Repository.SaveChangesAsync();
Hello Fabian,
Could you please inform what type of repository that you use? Is it EditableEntityRepository?
Also, could you please inform the error you received in details?
Thanks!
Yes, I am using the EditableEntityRepository.
I am getting a foreign key contraint violation. Especially if I add two or more childs.
Should I use another repository? Is there a code sample?
Have you tried the following?
this.Item = this.ItemRepository.Create(); // set the ItemId to avoid foreign key constraint violation Child child = new Child() { ItemId = this.Item.Id }; this.Item.Childs.Add(child); this.ItemRepository.Insert(this.Item); this.ChildRepository.Insert(child); this.ItemRepository.SaveChangesAsync(); this.ChildRepository.SaveChangesAsync();
Hope this helps.
This is working. But you have two change operations and server calls now.
1. This woul increase incoming traffic on the server. Bad if you have to pay for.
2. If you have two relations you would have to keep three repositories. More relations -> more repositories to keep. You would need more memory.
I would expect a more efficent way to get this done. Especially within an enterprise application. The "normal" entitie framework can handle this with just one call.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname