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.
C#.NET ProgrammingMicrosoft Development

Avatar of undefined
Last Comment
Gautham Janardhan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gautham Janardhan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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?
Gautham Janardhan

you wont be filtering your list view, but filtering your underlying collection,by setting the Filter in the ICollectionView
moshik008

ASKER
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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Gautham Janardhan

yes u need to set filter in icollectionview ,check this out

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