Link to home
Start Free TrialLog in
Avatar of moshik008
moshik008

asked on

Exposing the table and not the Ieditable object

Hi Experts,

this is the datacontext for my window:
namespace testApp
{
    class SupplierDataContext
    {
        public MyAppdataclassDataContext dataDC = new MyAppdataclassDataContext();
        private ICollectionView suppliers = null;
        public ICollectionView Suppliers
        {
            get
            {
                if (this.suppliers == null)
                {
                    ObservableCollection<Supplier> newSuppliers = new ObservableCollection<Supplier>();
                    foreach (tbl_Supplier s in dataDC.tbl_Suppliers)
                    {
                        newSuppliers.Add(new Supplier(s));
                    }
                    this.suppliers = new QueryableCollectionView(newSuppliers);
                }
                return this.suppliers;
            }
        }
    }
}

Open in new window


Supplier is a IeditableObject interface, when i am using this datacontext in my window the 'Supplier' is exposed, in my window i need to work with tbl_Supplier and the Supplier to be nested inside.

thanks.
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of moshik008
moshik008

ASKER

the difficult i have by going that way is to filter that binding in my window/
let's say i have the above class and i am binding some listview like:
somelistview.ItemsSource = new SupplierDataContext();

how do i filter the listview from my codebehind?
you wont be filtering your list view, but filtering your underlying collection,by setting the Filter in the ICollectionView
you mean to set the filter in the ICollectionView that in my separate class (above)?
or in my code of my window?
can you supply an example based on my class above?
thanks a lot.
yes u need to set filter in icollectionview ,check this out

http://marlongrech.wordpress.com/2008/11/22/icollectionview-explained/