ADO.NET Data Services - binding to WPF form RRS feed

  • Question

  • I created data service with ADO.NET EF model, put it to server, created client application and mapped one of the tables(entities) to observable collection, which was set as data source.

    in *xaml.cs file:

    public class ManagersCollection : ObservableCollection<Managers>
            ServiceEntities ServEnt = new ServiceEntities(new Uri("http://localhost:52535/WebDataService1.svc"));
            public ManagersCollection()
                base.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ManagersCollection_CollectionChanged);
                foreach (Managers man in (from e1 in ServEnt.Managers select e1))
    CurrentManagersCollection = (this.Resources["ManagersDS"] as ObjectDataProvider).ObjectInstance as ManagersCollection ;

    in *.xaml file:

            <ObjectDataProvider x:Key="ManagersDS" ObjectType="{x:Type obj:ManagersCollection}" />

    Everything works fine, BUT:
    - what if I need more than 1 table(entity) to be available for my WPF window at the same time? I have several tables and I need to operate them at the same time. Should I create separate collection with its own entities instance for each table or I can wrap them into single class with single entities instance and use my collections as nested classes of single main class?

    I tried to create such test class:

        public class AdvSchema
            public ServiceEntities ServEnt = new ServiceEntities(new Uri("http://localhost:51494/WebDataService1.svc"));
            public class ManagersCollection : ObservableCollection<Managers>
    But I found that my nested class isn't accessible from main class instance. So how can I combine all collections into single datasource which can be used as datacontext for my WPF form?
    Wednesday, February 10, 2010 9:21 PM


All replies