Newbie Question relating to multiple updates

Posts   
 
    
TSA
User
Posts: 2
Joined: 26-Sep-2011
# Posted on: 26-Sep-2011 05:17:18   

Hi,

I was after some advice or a starting point really.

We have a case where we have an object that is updated from an external source (a web service) at the same time (potentially) it is being used/updated by our custom client app. I.e the client app allows a user to click a button to call the webservice to retrieve a value - we wish to save that value back to the DB without committing all the other changes the user is making (we still want that to happen within the original workflow of the app when they hit 'save' for example).

The issue or advice I am after is, if I wish to persist this single value on our generated object that is being fetched from the external web service and save it to the db - without persisting any other changes to that object (i.e. what the user is doing within the client application), how would I best go about doing this?

I am aware of potential concurrency issues (i.e. multiple updates on the same object)

My algorithm (without knowing what LLBLGen is capable of) is to:

do an initial fetch to the db (user optionally may make changes to this object through the client app) call the web service do another fetch to get the original object make the web service change to the newly fetched original object save the newly fetch original object re-fetch from the db and set all the initial fetch values to it recursively (slow)

So thats the idea behind it, is there a way of having multiple updates to an object without having to refetch it and how do I go about updating only one property when saving?

Any help or general points in the right direction will be very much appreciated! simple_smile

Please note we are using a fairly old version of llblgen (which we can't upgrade atm unfortunately) - version 2.6

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Sep-2011 10:28:44   

I'm very confused here. Would you re-describe your case.

This is not about concurrency, is it?

Do you want to limit the update of a secific entity to a specific field or set of fields? Do you want this across the application (always) or just in a specific functionality.

If this is done by a webservice call, why don't you receive the new value from the user as well as the entity PK, then construct the entity in the service and save(update) it there.

TSA
User
Posts: 2
Joined: 26-Sep-2011
# Posted on: 27-Sep-2011 04:42:54   

It is related to concurrency and updating only one specific field (initially) and then allowing the same object to be updated later (without having to refetch from the db)... im after advice on how to go about doing this elegantly.

When we make the webservice call I want to save that value to the db straight away - i.e. the object being used by our calling client app - without committing any other changes that have occurred to that object by the user (that should happen when the user hits save on the UI).

So the issue is related to performing multiple updates on the same object and getting it to update initially to the db with just one specific field (ignoring any other changes) and still allow the user to save/update later if they choose to commit any other changes.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Sep-2011 09:05:10   

You have to have 2 web methods, one for the first update and one for subsequents updates.

In the first method, either you accept 2 parameters, the value to be updated and the PK. And hence you can call UpdateEntitiesDirectly(). Or you can accept the entity, but then you should loop on the fields and set IsChanged to false for each field except the one you need to update.

If you need concurrency control, then all these webmethods, should refetch the entity being saved and return it to the caller.