Print Page | Close Window

Four Step sample question

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1337
Printed Date: 19-Sep-2025 at 10:10am


Topic: Four Step sample question
Posted By: BenHayat
Subject: Four Step sample question
Date Posted: 19-Jun-2009 at 12:32pm
Hi;

In the Four step sample, as we load the Employees and we get the result back (same thing for orders), why do we need to iterate through the result list and add them to an IObservableCollection? Why can't the result be an IObservableCollection, so we can directly connect it to grid's ItemsSource?

Thanks!

p.s. I would like to expand upon my question. If we are using a "Middle man" ObservableCollection (i.e. _employess or _orders) which are connected to the UI but have no connection to the result coming form the server, how is change on the UI going to make back to the server?
I think that's why I'm asking why can't we connect the UI to result, so any changes to UI is recognized by EM.
Thanks!

-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com



Replies:
Posted By: GregD
Date Posted: 24-Jun-2009 at 4:19pm
Ben:

If you mean "why can't the result of the query be an IObservableCollection", I imagine the reason is that ObservableCollection is designed for UI purposes; whereas the query results may be needed for many different kinds of uses, for many of which a lighter-weight collection is entirely adequate.

You can, of course, refactor the foreach operation so you can do it a bit more succinctly.

>>
p.s. I would like to expand upon my question. If we are using a "Middle man" ObservableCollection (i.e. _employess or _orders) which are connected to the UI but have no connection to the result coming form the server, how is change on the UI going to make back to the server?
<<

Not sure which change you're talking about. All changes to the entities in the collection (Observable or otherwise) will get back to the server (and the backing store) via SaveChanges().



Print Page | Close Window