Hi, I have asked this question on more than one forums and it seems no one would even want to take a crak at it.
My problem is simple and i would guess everyone has run into it when using LINQ to SQL.
If your have a LINQ object called: Person and you would like to poulate a list box based on all of the people you have in your DB the task is simple:
BindingListCollectionView view;
view = (BindingListCollectionView)CollectionViewSource.GetDefault (dataContext.Persons);
Now say you wish to have a text box over the list to filter the results. that would not work since IBindingList interface implemented by the LINQ to SQL objects returns false on "CanFilter" property.
What most people do is create an ObservebleCollection, the folloing is an example im sure most of you use.
ObservebleCollection<Person> col = new ObservebleCollection<Person>(dataContext.Persons.ToList());
ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefault(col);
Since this will return a ListCollectionView and not a BindingListCollectionView it will be filterbale and all is well with the world.
Here comes the problem, say you have Multi levels of Forign key relations: Person<---Alias<---Tickets
and now you wish to have 3 list boxes binded when a person is selected the second list box will diplay only his Alias's and when an Alias is selected only it's Ticket's are shown, this is very simple with binding and syncronizing. the problem is if i want to add a textbox filter on tob of all of the listboxes ( say a person has over 1000 Aliases and i want to be able to filter them to choose 1 ).
The prvious solution of ObservebleCollection will not work since all the Person objects returned will have EntitySet objects for the forgin relation, and this will again return a none filterbale BindingListCollectionView and not a ListCollectionView.
The only way i found around this is to manually bulid an ObserverbleCollection based on the retunred Query this is tedious work and causes me to tie the BusnessObjects layer and the application Layer. also its very slow since you need to make many trips to the database...
Does anyone have a solution to this?
Thanks, Eric.