views:

149

answers:

1

I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class (maybe NHibernate class) and prepared it special for View layer binding.

I have few Silverlight page, so should I create for each page separate service class ? Or create one interface and all method will implement it in one service class?

Do You have some advice helped with my with services ?

+1  A: 

I would go with a Service abstraction for the data access like done in the Repository Pattern. Have an Interface Like IDataService and then implement all the code containing the service there. It would be also possible to have one implementation for NHibernate, WCF Ria Service, Webservice.

Here is one example: http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2807 here is another one: http://msmvps.com/blogs/theproblemsolver/archive/2009/02/18/getting-started-with-the-repository-pattern-in-silverlight.aspx

hope this helps..

silverfighter
Second link explain me pattern very well. I only take a look in code of this example to understand how it bind to DataContext.. Do You think that it's possible to bind ItemSource property of ListBox ? I only start learning a NHibernate and I am sure that Your advice help me much! :)
netmajor
Sure you can also use the Listbox ItemSource too. You can subscripe to the loaded event on the Silverlight Page. Then bind to the ItemsSource. Also look for MVVM this is another pattern to seperate Business Logic from visualization. HTH
silverfighter