delete from prefetched level 2, recursive update?

Posts   
 
    
zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 01-Aug-2008 20:06:06   

Hello.. i am wondering if this is possible.. im using the adapter with a WCF...

_Public Function GetPackage(ByVal PackageId As Integer) As PackageEntity Implements IService1.GetPackage Dim adapter As New DataAccessAdapter() Dim Package As New PackageEntity(PackageId) Dim path As PrefetchPath2 = New PrefetchPath2(CType(EntityType.PackageEntity, Integer)) path.Add(PackageEntity.PrefetchPathPackageMedia).SubPath.Add(PackageMediaEntity.PrefetchPathMedia)

    adapter.FetchEntity(Package, path)

    Return Package
End Function_

The above gets me the package...

then hopefully using a _Function Update_Package(ByVal _Package As IEntity2, ByVal recursive As Boolean) As Boolean Implements IService1.Update_Package Dim adapter As New DataAccessAdapter() If adapter.SaveEntity(DirectCast(_Package, PackageEntity), False, recursive) Then Return True Else Return False End If

End Function_

i should be able to save my changes..

it is my understanding that after i get the package., i can modify it., and then send it back... and since the pk contains the value for the entity., it should save the changes made to it., and a recursive set to tru should update all 2nd level collections that were prefetched?

also..

in my client application... i am trying to remove / add items to the 2nd level collection by

For Each _packageMedia As PackageMediaEntity In _Package.PackageMedia If _packageMedia.PackageMediaId = lv_selectedmedia.Items(0).Tag Then lv_selectedmedia.Items(0).Remove() _Package.PackageMedia.Remove(_packageMedia) Exit Sub End If Next

i have a listview., and a remove button., once you selecte an item., and click remove it should be able to do a match and remove the item from the collection.,

is that correct? would the same apply if i did a add?

also... looking at the add function,. if i try to throw in dupes it should filter out the already existing ones? ( saw that somewhere in the manual... its what i want)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Aug-2008 04:31:36   

it is my understanding that after i get the package., i can modify it., and then send it back... and since the pk contains the value for the entity., it should save the changes made to it., and a recursive set to tru should update all 2nd level collections that were prefetched?

Yes. Are you experimenting something different? At server side the tree is sent complete? If it isn't it's probably something about serialization. (LLBLGen runtime libraries version? )

i have a listview., and a remove button., once you selecte an item., and click remove it should be able to do a match and remove the item from the collection.,

is that correct? would the same apply if i did a add?

If the collection is bound to the control, yes it should. That depends on how you are binding it and what control are you using (if it supports that). So, if it is bound, you should only add/remove at the control and it should remove/add to the collection. Remember that if you delete an entity from a collection, that doesn't means the entity will be deleted from database (please see the docs, RemovedEntitiesTracker ).

also... looking at the add function,. if i try to throw in dupes it should filter out the already existing ones? ( saw that somewhere in the manual... its what i want)

sorry, I don't understand that.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 02-Aug-2008 11:26:47   

If you don't want duplicates to appear, set the property DoNotPerformAddIfPresent to true on the collection. Be aware that this will perform a linear search for every add, hence the default of 'false'.

Frans Bouma | Lead developer LLBLGen Pro
zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 05-Aug-2008 22:47:08   

let me double check what i did to get things working for now., right now im lost in combobox bindings with sub paths simple_smile

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Aug-2008 04:10:49   

zee wrote:

let me double check what i did to get things working for now., right now im lost in combobox bindings with sub paths simple_smile

Could you please be more specific? An example would be helpful. What isn't working?

David Elizondo | LLBLGen Support Team
zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 13-Aug-2008 19:42:49   

sorry. here is the other thread http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14032

as for as inserting data with no duplicates.... i am guessing that the primary key is what is checked for duplicated data before insert? i think the dba has incorrectly defined the tables sequences as the primary key....