LLBLGen, RIA and Silverlight

Posts   
 
    
ottoacosta
User
Posts: 34
Joined: 16-Aug-2007
# Posted on: 18-Mar-2011 21:09:08   

Hi guys,

Using: - LLGLGen Pro V3.1 - VS 2010 - Silverlight 4 - Oracle 10/11g

I finally found the time to start using the LLBLGen RIA support libraries and due to the Asynchronous nature of RIA and the fact that some of the operations been performed by our current application make affect 6-7 entities, including adding new ones or updating/referencing existing ones, what's the best way to check on whether or not an entity exists before invoking context.Add(Entity).

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Mar-2011 11:51:09   

Ho Otto,

Could you please elaborate more on that? Please show us a code snippet example of what you want to achieve.

David Elizondo | LLBLGen Support Team
anlebu
User
Posts: 10
Joined: 19-Jan-2011
# Posted on: 23-Mar-2011 16:10:22   

you do context.Add only to add a new entity, normally you have to do the Load operation instead. I have been able to do a lot of things using RIA services, but there are some tricks like marking the entityfields as changed, setting the isNew flag, removing the isOutofSync on the returned values(including originals) all this is done at the domainservice level using the this.ChangeSet. In my case I implemented my own bol so I did not call the DomainService base to do the crud operations, instead i used my existing bol logic, but i used the DomainService base as the entry point of my ria services.

ottoacosta
User
Posts: 34
Joined: 16-Aug-2007
# Posted on: 23-Mar-2011 16:29:40   

It becomes a little tricky, at least in my case, when you have to go to the database and find out whether or not an entity matching the user-provided attributes already exists all during an asynchronous save operation. What I have done is to be proactive by trying to load a matching entity when the user makes changes to those key attributes on the UI. If the entity is found I then set the ID(FK) to any other related entities, if the entity is not found I then just create the new entity, add all related entities to it and then add the entity to the data context and invoke SubmitChanges. That seems to be working fine for me.

I am going to create a new thread for some other questions I have. I will add a link on this one.

Thanks guys.