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

Filtering issue QueryableEntityCollectionView with EF

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 18 Mar 2016, 09:22 AM

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

1 Answer, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 18 Mar 2016, 03:17 PM

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

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

Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Share this question
or