Hi,
I have an entitycollection which can be altered multiple places in an mdi windows application. While this works flawlessly in most cases, I can not figure out how to fetch entities into a given collection while not fetching the entities already present.
I have the following table hierarchy:
Case -> Case2Item -> Item
Case -> Case2TurbineUnitType -> Case2TurbineUnitType2Case2Item -> Case2Item -> Item
In my application this means I have multiple ways of manipulating the Case2Item table. What I need is, that when I have fetched the relevant Case2Item entries in one window, I would like to fetch the remaining Case2Item entries via another fetch in another window. I actually need to do this in a prefetchpath and have tried the following:
Using daa As New DataAccessAdapter(True)
Dim filterBucket As IRelationPredicateBucket = New RelationPredicateBucket()
filterBucket.PredicateExpression.AddWithAnd(Case2TurbineUnitTypeFields.CaseId = CaseId)
Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(EntityType.Case2TurbineUnitTypeEntity)
Dim ppe As IPrefetchPathElement2 = prefetchPath.Add(Case2TurbineUnitTypeEntity.PrefetchPathCase2TurbineUnitType2Case2Item)
Dim ppf As IPredicateExpression = New PredicateExpression()
For Each entity As Case2ItemEntity In oCase.Case2Item
ppf.AddWithAnd(Case2ItemFields.Case2ItemId <> entity.Case2ItemId)
Next
ppe.SubPath.Add(Case2TurbineUnitType2Case2ItemEntity.PrefetchPathCase2Item, 0, ppf).SubPath.Add(Case2ItemEntity.PrefetchPathItem).SubPath.Add(ItemEntity.PrefetchPathERPSystem)
daa.FetchEntityCollection(ecSave, filterBucket, prefetchPath)
daa.CloseConnection()
End Using
However this does not seem to work as I get duplicate entries from the Case2Item table in my subsequent object model. How do I solve this?
I am using LLBL 2.0.0.0 October 3rd edition, SQL Server 2000 database, Adapter template.
I am looking forward to hearing from you.
Regards,
Michael Fastrup