This is a migrated thread and some comments may be shown as answers.

Filtering EntityCollection type field by filter descriptor in VB.NET

1 Answer 143 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Atul
Top achievements
Rank 2
Atul asked on 31 Jan 2013, 02:02 PM
I have a QueryableCollectionView which is bind with the entity and the entity has a child entity collection. I am filtering this queryable collection by creating filter descriptors and adding them to the collections.
            For string and boolean field it is very easy to create a filter descriptor like this:

 Dim FolderIDFD As New FilterDescriptor
            FolderIDFD.Member = "FolderID"
            FolderIDFD.Operator = FilterOperator.IsEqualTo
            FolderIDFD.Value = SelectedUserFolder.Id
            MediaCollectionView.FilterDescriptors.Add(FolderIDFD)

But for filtering an entitycollection field how can be this possible?

i want to filter a field which child of child of the collection, for this first i have to ensure that the child entity collection should not be nothing
in first condition.
Than how can i implement the filter descriptor for an EntityCollection field?

I have also used

Dim UnProfiledFD As New FilterDescriptor
        UnProfiledFD.Member = "TaggedMediums"
        UnProfiledFD.Operator = FilterOperator.IsNotNull

        MediaCollectionView.FilterDescriptors.Add(UnProfiledFD)

but it is not working for entityCollection field.

1 Answer, 1 is accepted

Sort by
0
Atul
Top achievements
Rank 2
answered on 07 Feb 2013, 06:07 AM
Here i am able to filter my child entity collection by IsNull and also IsNotNull conditions :

Dim FolderIDFD As New FilterDescriptor
        FolderIDFD.Member = "TaggedMediums"
        FolderIDFD.Operator = FilterOperator.IsNotNull
        MediaCollectionView.FilterDescriptors.Add(FolderIDFD)

     But also able to filter the entity collection field by this:

Dim FolderIDFD As New FilterDescriptor
        FolderIDFD.Member = "TaggedMediums.Count"
        FolderIDFD.Operator = FilterOperator.IsGreaterThan
        FolderIDFD.Value = 0
        MediaCollectionView.FilterDescriptors.Add(FolderIDFD)

   Can you help me to filter the child collection from its field like  "TaggedMediums.TagID"
That means i want to filter the collection by the child entity collection's field i.e. TagID, can i use "CreateFilterExpression" for this type of filtration.
           If it is possible then help me to do this by showing an example for filtering via "CreateFilterExpression".
Tags
DataFilter
Asked by
Atul
Top achievements
Rank 2
Answers by
Atul
Top achievements
Rank 2
Share this question
or