Filtering EntityCollection type field by filter descriptor in VB.NET

2 posts, 0 answers
  1. Atul
    Atul avatar
    2 posts
    Member since:
    Dec 2010

    Posted 31 Jan 2013 Link to this post

    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.
  2. Atul
    Atul avatar
    2 posts
    Member since:
    Dec 2010

    Posted 07 Feb 2013 Link to this post

    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".
Back to Top