- Home
- LLBLGen Pro
- Bugs & Issues
Filter is not working on Sub items (i.e ProcessStepchildren)
Joined: 25-Apr-2018
Hi Team,
I have a issue like when i am using checkboxes and a search control to filter out records in my Gridview. Filter expression is working on the processStep items but not on the ProcessStepChildren (Subitems).
I have following function included in my code:
Public Overrides Function GetPrefetchPath() As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
query to retrive final result after applying filters:
Dim ec As New EntityCollection(Of ProcessStepEntity)()
DataAccessAdapter.FetchEntityCollection(ec, bucket, limit, sort, GetPrefetchPath(), Nothing, CInt((startRow / maxRows) + 1), maxRows)
Final result i am getting is only 4 shows which consists of only parent processSteps . predicate filter is not being applied to ProcessStepChildren(Subitems). Thats why Sub items are not getting filtered. Can you please tell me a workaround to also include processStepchildren under filter criteria. In case you need full function of bucket then please do let me know about it. I will share the same.
Joined: 21-Aug-2005
Final result i am getting is only 4 shows which consists of only parent processSteps . predicate filter is not being applied to ProcessStepChildren(Subitems). Thats why Sub items are not getting filtered. Can you please tell me a workaround to also include processStepchildren under filter criteria.
You can add a filter criteria (PredicateExpression & RelationCollection) to the PreftechPath. ref: http://www.llblgen.com/documentation/5.4/ReferenceManuals/LLBLGenProRTF/html/3304525F.htm
Joined: 25-Apr-2018
Hi Walaa,
Thanks for your reply !!
But as you can see i have already added processStepchildren in prefetchpath
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
I am having trouble with my bucket code. I am also sharing my bucket code below:
Public Function produceSearchCriteria(ByVal supplier As String, ByVal createdby As String, ByVal pno As String, ByVal vui As String, _ ByVal itemnumber As String, ByVal serialnumber As String, ByVal processStepDateFrom As String, ByVal processStepDateTo As String, _ ByVal orderDateFrom As String, ByVal orderDateTo As String, ByVal serialNumberFrom As String, ByVal serialNumberTo As String, _ ByVal setNumber As String, ByVal setVUI As String, ByVal setSerialNumber As String, ByVal supplierItemNo As String, _ ByVal supplierOrderNo As String) As IRelationPredicateBucket
Dim bucket As New RelationPredicateBucket
bucket.Relations.Add(OrderEntity.Relations.ProcessStepEntityUsingOrderId, JoinHint.Right)
bucket.Relations.Add(ProcessStepEntity.Relations.SupplierEntityUsingSupplierId)
bucket.Relations.Add(ProcessStepEntity.Relations.ItemEntityUsingItemId)
bucket.Relations.Add(ProcessStepEntity.Relations.SerialEntityUsingSerialId, JoinHint.Left)
If supplier <> String.Empty Then
Dim supplierSearch As New PredicateExpression()
Dim number As String = SqlUtility.ValidateSqlParameter(supplier.Replace("*", "%"))
Dim nameSearch As New PredicateExpression((SupplierFields.Name Mod number And SupplierFields.Number Mod "U%"))
Dim numberSearch As PredicateExpression = New PredicateExpression(SupplierFields.Number Mod number)
Dim notU As PredicateExpression = New PredicateExpression(SupplierFields.Number Mod "U%")
notU.Negate = True
numberSearch.AddWithAnd(notU)
supplierSearch.AddWithAnd(nameSearch)
supplierSearch.AddWithOr(numberSearch)
bucket.PredicateExpression.AddWithOr(supplierSearch)
End If
If createdby <> String.Empty Then
bucket.Relations.Add(SupplierEntity.Relations.UserEntityUsingSupplierid)
bucket.PredicateExpression.AddWithAnd(UserFields.Username Mod SqlUtility.ValidateSqlParameter(createdby.Replace("*", "%")))
End If
If pno <> String.Empty Then
bucket.PredicateExpression.AddWithAnd(OrderFields.OrderNo Mod SqlUtility.ValidateSqlParameter(pno.Replace("*", "%")))
End If
If vui <> String.Empty Then
Dim vuiValue As String = SqlUtility.ValidateSqlParameter(vui.Replace("*", "%"))
bucket.PredicateExpression.AddWithAnd(ProcessStepFields.Vui Mod vuiValue Or ProcessStepFields.OldVui Mod vuiValue)
End If
If itemnumber <> String.Empty Then
Dim itnbr As String = SqlUtility.ValidateSqlParameter(itemnumber.Replace("*", "%"))
Dim itemSearch As New PredicateExpression(ItemFields.Itnbr Mod itnbr)
Dim notUU As New PredicateExpression(ItemFields.Itnbr Mod "UU%")
notUU.Negate = True
itemSearch.AddWithAnd(notUU)
Dim descriptionSearch As New PredicateExpression(ItemFields.Description Mod itnbr)
descriptionSearch.AddWithAnd(notUU)
itemSearch.AddWithOr(descriptionSearch)
bucket.PredicateExpression.AddWithAnd(itemSearch)
End If
If serialnumber <> String.Empty Then
bucket.PredicateExpression.AddWithAnd(SerialFields.Number Mod SqlUtility.ValidateSqlParameter(serialnumber.Replace("*", "%")))
End If
If serialNumberFrom <> String.Empty And serialNumberTo <> String.Empty Then
bucket.Relations.Add(ProcessStepEntity.Relations.SerialEntityUsingSerialId)
' Nothing parameter used in order to force the usage of an overload that takes an IEntityFieldCore instead of IEntity
bucket.PredicateExpression.AddWithAnd(New FieldBetweenPredicate(SerialFields.Number, Nothing, SqlUtility.ValidateSqlParameter(serialNumberFrom), SqlUtility.ValidateSqlParameter(serialNumberTo)))
End If
If serialNumberFrom <> String.Empty And serialNumberTo = String.Empty Then
bucket.PredicateExpression.AddWithAnd(SerialFields.Number > SqlUtility.ValidateSqlParameter(serialNumberFrom))
End If
If serialNumberFrom = String.Empty And serialNumberTo <> String.Empty Then
bucket.PredicateExpression.AddWithAnd(SerialFields.Number < SqlUtility.ValidateSqlParameter(serialNumberTo))
End If
If processStepDateFrom <> String.Empty Then
bucket.PredicateExpression.AddWithAnd(ProcessStepFields.CreatedTs >= SqlUtility.ValidateSqlParameter(SqlUtility.Cast2DateString(processStepDateFrom)))
End If
Return Bucket End function
Can you please check where i am committing mistake in my bucket function. Where to add bucket predicate expression to include processStepChildren in filter criteria. Your help is much needed.
Joined: 21-Aug-2005
That what my previous reply was about.
When you fetch a collection, any filter (bucket) you will use will take effect on the fetched collection, not its related (child) entities which are fetch using prefetchPaths.
If you want to filter entities in the prefetchPaths, you need to provide filtering (bucket) to the prefetchPath itself, through the .Add() method.
Check the .Add() overload I've linked up.
Joined: 25-Apr-2018
Hi Walaa,
I have tried but i am not able to add processStep children under filter criteria using the above link.
Can you please help me in doing that !!
Joined: 25-Apr-2018
For better clearity let me show you how i have added processStep Children in prefetchpath.
Public Overrides Function GetPrefetchPath() As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.**PrefetchPathProcessStepChildren**)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
Definition of PrefetchPathProcessStepChildren added using ADD function is mentioned below:
Public Shared ReadOnly Property PrefetchPathProcessStepChildren() As IPrefetchPathElement2 Get Return New PrefetchPathElement2( New EntityCollection(Of ProcessStepEntity)(EntityFactoryCache2.GetEntityFactory(GetType(ProcessStepEntityFactory))), _ CType(GetRelationsForField("ProcessStepChildren")(0), IEntityRelation), CType(Vestas.Nacelle.ComponentDoc.LLBL.EntityType.ProcessStepEntity, Integer), CType(Vestas.Nacelle.ComponentDoc.LLBL.EntityType.ProcessStepEntity, Integer), 0, Nothing, Nothing, Nothing, Nothing, "ProcessStepChildren", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany) End Get End Property
As you can see above i have already added processStep children using 'ADD' function in prefetchpath then why filter(bucket) is not being applied on it??
Joined: 28-Nov-2005
There is an overload on the IPrefetchPath.Add(..) method that accepts a predicate expression object, that predicate is used to filter the prefetched collection. That was the link Walaa posted above, the link that documents that variant of the .Add method. Maybe you would need to build a filter just for the prefetchPath. Example:
Dim propPPFilter As New PredicateExpression()
propPPFilter.Add(ProcessStepChildrenFields.FieldA == "SomeValue")
propPPFilter.AddWithOr(ProcessStepChildrenFields.FieldB == "SomeOtherValue")
...
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, 0 propPPFilter, Nothing)
Note that above I built an specific predicate for the prefetchPath element. You should do the same for every path element you want to filter. If the predicate expression involves another related table (related to that element, in this case ProcessStepChildres) you should add a RelationCollection in the last parameter of that .Add method overload.
Joined: 25-Apr-2018
this has confused me more david. Can you please eloborate it using my code entities.
i am not able to add filtering (bucket) to the prefetchPath using the .Add() method.
Joined: 25-Apr-2018
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, 0 propPPFilter, Nothing)
One more thing david,in the above statement '0' refers to the "Maximum amount of items to fetch of the set of entities specified by the element"??
Joined: 25-Apr-2018
Ok i guess there is only one problem where i am stucked.
Dim bucket As RelationPredicateBucket = CType(ProcessStepSearch.RelationPredicateBucket, RelationPredicateBucket)
In the above statement all the filter included in 'ProcessStepSearch' have been passed into bucket as relationpredicate bucket.
Now we need to add this bucket as an addtional filter in IPrefetchPathElement2 i.e
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, 0,'How can i add bucket over here', Nothing)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
please help me in adding bucket to add function
Joined: 21-Aug-2005
the prefetchPath.Add() method, has an overload that accepts a PredicateExpression and RelationCollection as 2 separate parameters.
It doesn't accept a RelationPrecdicate bucket, as stated in the Reference Manual. If you already have a RelationPredicateBucket object, it's ok, as it holds both of these parameters (you have used them when building the bucket) so you can pass them as follows:
buckt.PredicateExpression, bucket.Relations
(ProcessStepEntity.PrefetchPathProcessStepChildren, 0,'How can i add bucket over here', Nothing)
Did I answer you?
Joined: 25-Apr-2018
yes wala thats resolve my confusion. But when i am passing '0' as maximum amount to return , its not fetching ProcessStepChildren now.
What could be the reason?
Joined: 25-Apr-2018
Hi Walaa,
When i am using : DataAccessAdapter.FetchEntityCollection(ec, bucket, limit, sort, GetPrefetchPath(), Nothing, CInt((startRow / maxRows) + 1), maxRows)
With Getprefetchpath() function as:
Public Overrides Function GetPrefetchPath() As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
Result is fetching processStepchildren without applying filter on it.
Now when i have changed the code like this : DataAccessAdapter.FetchEntityCollection(ec, bucket, limit, sort, GetPrefetchPath_3(bucket), Nothing, CInt((startRow / maxRows) + 1), maxRows)
Public Function GetPrefetchPath_3(ByVal bucket As IRelationPredicateBucket) As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, Nothing, bucket.PredicateExpression, bucket.Relations)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
Its not fetching processStepChildren, and returning resultset containing only parent processStepEntities. I am not even sure whether any bucket filter has been applied on processStepchildren or not.
Can you please tell me where i am committing the mistake?
Joined: 25-Apr-2018
Bucket value has been transferred from this expression:
Protected Sub ObjectDataSource_Items_Selecting(ByVal sender As Object, ByVal e As ObjectDataSourceSelectingEventArgs) _ Handles ObjectDataSource_OrderItems.Selecting
Dim sort As SortExpression = New SortExpression
Dim bucket As RelationPredicateBucket = CType(ProcessStepSearch.RelationPredicateBucket, RelationPredicateBucket) .. .. e.InputParameters("bucket") = bucket e.InputParameters("sort") = _sort.SortExpression() e.InputParameters("limit") = Utility.GetAmountToShowOnLists e.InputParameters("flatten") = True End Sub
Joined: 21-Aug-2005
Its not fetching processStepChildren, and returning resultset containing only parent processStepEntities. I am not even sure whether any bucket filter has been applied on processStepchildren or not.
Maybe the filter doesn't allow any records to return, so it filters out all records. There is one way to find out and also to answer your question, whether filtering has been applied or not.
You need to examine the generated SQL query and run it manually against the database in MSSQLMS or something similar to see if it returns any results, and if not, then why?
To do so, please enable Dynamic Query Engine Tracing, debug the application and watch the output window for the SQL executed.
Joined: 25-Apr-2018
Hi walaa,
Genius you are buddy !!
You were right. There was a problem in SQL query which is generated by applying bucket filter on ProcessStepChildren. It was including "AND ( ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NOT NULL)))" in the query generated for processStepchildren.
now i have changed the code like this but its creating a diffrent problem:
Public Function GetPrefetchPath_3(ByVal bucket As IRelationPredicateBucket) As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
bucket.PredicateExpression.AddWithOr(ProcessStepFields.Parent <> DBNull.Value)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, Nothing, bucket.PredicateExpression, bucket.Relations)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
But now its applying this condition "" AND ( ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL)) Or ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NOT NULL)))) to the parent processStep as well (
I am a new developer for this LLBLgen technology, that's why asking you a lot of things. I hope you will not mind that
Joined: 25-Apr-2018
Hi Walaa,
please can you also tell me how to delete a expression from a Predicate bucket like in below query:
WHERE ( ( ( [ComponentDoc].[dbo].[ProcessStep].[Completed] = @p3 AND [ComponentDoc].[dbo].[ProcessStep].[Approved] = @p4 AND [ComponentDoc].[dbo].[ProcessStep].[Annulled] = @p5) OR ( [ComponentDoc].[dbo].[ProcessStep].[Completed] = @p6 AND [ComponentDoc].[dbo].[ProcessStep].[Approved] = @p7 AND [ComponentDoc].[dbo].[ProcessStep].[Annulled] = @p8)) AND ( ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL) AND ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL AND ( ( ( ( [LPA_P1].[Itnbr] = @p9) AND NOT ( [LPA_P1].[Itnbr] LIKE @p10)) OR ( ( [LPA_P1].[Description] = @p11) AND ( [LPA_P1].[Itnbr] LIKE @p12))) OR ( ( ( [LPA_C3].[Itnbr] = @p13) AND NOT ( [LPA_C3].[Itnbr] LIKE @p14)) OR ( ( [LPA_C3].[Description] = @p15) AND ( [LPA_C3].[Itnbr] LIKE @p16))))) AND ( [ComponentDoc].[dbo].[Order].[OrderId] = @p17) AND ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL) AND ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL) AND ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL))) ORDER BY [ComponentDoc].[dbo].[ProcessStep].[Vui] ASC,[ComponentDoc].[dbo].[ProcessStep].[ProcessStepId] ASC
I want to remove this expression '( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL) ' which is frequently occuring in above query.
Joined: 25-Apr-2018
Its not even working if i make changes like below:
Public Function GetPrefetchPath_3(ByVal bucket As IRelationPredicateBucket) As IPrefetchPath2 Dim prefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.ProcessStepEntity, Integer))
prefetchPath.Add(ProcessStepEntity.PrefetchPathItem)
prefetchPath.Add(ProcessStepEntity.PrefetchPathOrder)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSerial)
prefetchPath.Add(ProcessStepEntity.PrefetchPathSupplier)
prefetchPath.Add(ProcessStepEntity.PrefetchPathDocument)
prefetchPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Dim bucket2 As New RelationPredicateBucket
bucket2 = CType(bucket, RelationPredicateBucket)
bucket2.PredicateExpression.AddWithOr(ProcessStepFields.Parent <> DBNull.Value)
Dim proPP As IPrefetchPathElement2 = prefetchPath.Add(ProcessStepEntity.PrefetchPathProcessStepChildren, Nothing, bucket2.PredicateExpression, bucket2.Relations)
' fetch set items
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathSerial)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathItem)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathDocument)
proPP.SubPath.Add(ProcessStepEntity.PrefetchPathCreateUser)
Return prefetchPath
End Function
AND ( [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NULL)) OR [ComponentDoc].[dbo].[ProcessStep].[Parent] IS NOT NULL) is still being applied on Parent ProcessStep Entities which i dont want. I just want it to get applied only for Child ProcessStepChildren !!
Joined: 25-Apr-2018
yes Walaa.
But Both ProcessStepChildren And ProcessStepparent have unique ProcessStepId's to identify and filter them .
Joined: 25-Apr-2018
hi walaa,
I have attached a screenshot along with this message to give exact idea about processStep Entity.
Please check
Filename | File size | Added on | Approval |
---|---|---|---|
ProcessStepEntity.jpg | 279,621 | 29-Jun-2018 12:41.19 | Approved |
Joined: 28-Nov-2005
It's not really an inheritance. Is a recursive relation: ProcessStep -> ProcessStep, producing the navigators ProcessStep.ProcessStepParent (1) and ProcessStep.ProcessStepChildren (n).
Now, back to the issue. As I can see you want two things: filter the main results (parents), and when fetching the children (prefetchPath), filter those as well. The problem is that you are using the same RelationPredicateBucket to both the parents and children.
See this example (I know it's not your code, but is to clarify the concepts a little bit). In the example, I want to fetch ALL Customers from India. For each customer I want to pre-fetch all his orders which the Total amount is greater than 1000. As you can see, you want to filter the main collection (all customers from India), and you also want to filter the prefetched orders collection (total > 1000). Those are two different filters. This would be written like this:
// this filter is for the prefetched order collection
Dim orderFilter As New PredicateExpression(OrderFields.Total > 1000)
Dim prefetchPath As New PrefetchPath2(EntityType.CustomerEntity)
prefetchPath.Add(CustomerEntity.PrefetchPathOrders, Nothing, customerFilter, Nothing)
// this filter is for the main collection
Dim customerFilter As New RelationPredicateBucket(CustomerFields.Country.Equal("India"))
Dim customers As New EntityCollection(Of CustomerEntity)()
Using adapter As New DataAccessAdapter()
adapter.FetchEntityCollection(customers, customerFilter, prefetchPath)
End Using
As above example, you also need to use two different filters for ProcessStep (the parents) and ProcessStep (the children):
DataAccessAdapter.FetchEntityCollection(ec, bucket, limit, sort,
GetPrefetchPath_3(anotherBucket),
Nothing, CInt((startRow / maxRows) + 1), maxRows)
In above code, you need to create anotherBucket which is different from bucket. Then you add to anotherBucket just the predicates you are interested in for filtering the children.
Hope that makes sense to you.