views:

368

answers:

1

Hi, All

I have implemented Linq-To-Sql.. Add necessary table in it... after that linq class will automatically set property for field.. I implemented one class using observable collection class.. and pass datacontextclass object in its constructor...

so after getting all data how to filter it ?

  public class BindBookIssueDetails : ObservableCollection
        {
            public BindBookIssueDetails(DataClasses1DataContext dataDC)
            {
                foreach (Resource_Allocation_View res in dataDC.Resource_Allocation_Views)
                {
                    this.Add(res);
                }
            }
        }

private BindBookIssueDetails bResource;
bResource = new BindBookIssueDetails(db);
_cmbResource.ItemSource=bResource;

Please Help me.

A: 

You can use CollectionViewSource and filter it. So that it affect only at the View(.XAML) side

    ICollectionView collectionView = CollectionViewSource.GetDefaultView(bResource);
    collectionView.Filter = new Predicate<object>(YourFilterFunction);

Check out this blog for more details.http://bea.stollnitz.com/blog/?p=31

Jobi Joy