Print Page | Close Window

Insert / Update

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2921
Printed Date: 25-Mar-2025 at 9:34am


Topic: Insert / Update
Posted By: daw451
Subject: Insert / Update
Date Posted: 24-Aug-2011 at 6:19am

do I need to check for the existence of a row to decide whether to do an update or an insert? Is there a way to attach the entities and do an async save and let ideablade determine whether to update it or insert it.

Thanks



Replies:
Posted By: DenisK
Date Posted: 24-Aug-2011 at 10:13am
Hi Aaron;

This sounds like a similar question you had sent to our support system. I've replied to this question yesterday at 7:26 pm so I'm assuming you did not get it. Here's my reply again.

Hi Aaron;

Ok, I'm still not entirely clear on your questions so I'm just going to give my assumptions and possible answers here.

Assumption 1: You have a database view made up from some tables exposed to your ViewModel and DevForce is used to retrieve, insert and update data from that view. You're asking whether you should check the existence of a row first in the table to decide whether to do an insert or update.

Answer 1: No you don't need to check or do an AttachEntity. If you make your database view updatable (as shown here, http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx - http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx .) any insert/update you make to the database view is automatically handled by EntityFramework and applied to its corresponding table(s).

Assumption 2: You have the view-backed entity and then other entity types representing tables in that view and it is in fact updatable.

Answer 2: EntityFramework, not DevForce, will determine how to insert/update the underlying tables when you make changes to instances of this entity type. You don’t need to do an attach or anything else. You can query these entities into cache and then make modifications as usual.

Conclusion: Regardless of whether you already have an updatable view or not, we delegate all of this to EntityFramework so whatever EntityFramework supports, we do too.

Hope this helps.

Regards,
Denis



Print Page | Close Window