Filtering issue QueryableEntityCollectionView with EF

2 posts, 0 answers
  1. Eric
    Eric avatar
    4 posts
    Member since:
    Aug 2010

    Posted 18 Mar Link to this post

    Hi,

    Not sure where to put this issue so general discussion perhaps the best place.

    I'm using a MVVM model, with the telerik controls WPF TreeView, WPF GridView, WPF DataForm. 
    As a data backend I'm using Entity Framework code first. This mock-up project works really great.

    I'm having an issue with filtering the data of the QueryableEntityCollectionView which I use as a source of the WPF GridView and WPF DataForm.
    Filtering is defined as FilterDescriptor filterDeleted = new FilterDescriptor("IsDeleted", FilterOperator.IsEqualTo, false); works just fine.

    Now I want to filter on a property of a subobject; Person class has a property Club. Club is also a class.
    As the FilterDescriptor is not able to filter on FilterDescriptor("Club.Id", FilterOperator.IsEqualTo, 10);
    I've added an Additional propertie in the Model

    [NotMapped]
    [DisplayName("ClubId")]
    public int ClubId         
    {             
        get             
               {                 
                   
    return Club == null ? -1 : Club.Id;
               
    }
    }

    Defining a FilterDescriptor FilterDescriptor("ClubId", FilterOperator.IsEqualTo, 10) is not working, result is no records at all.
    Testing with for example PersonID instead of ClubId works fine.
    I've also have a similar ClubId property for calculating Age of person. Filtering on age doesn't work as well. Seems that members not original referencing to table column are not working?

     

    Eric

  2. Eric
    Eric avatar
    4 posts
    Member since:
    Aug 2010

    Posted 18 Mar in reply to Eric Link to this post

    Still don't know why my approach didn't work.
    Fixed this by using:

    new FilterDescriptor<Person> { FilteringExpression = e => e.Club.Id == 10 };

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top