locked
Disadvantage of DomainDataSource and Alternative? RRS feed

  • Question

  • Hi

    In my Application i use a lot of DomainDataSources to get Data from my SQL Server tables to my Application.
    For example to fill DataGrids, ComboBoxes, and so on.

    I am now unsure if this is the best way to get the Data to my App, or if there are any other Ways. The Problem is that if i use the same Data for like 2 DataGrids, and filter the DomainDataSource, both DataGrid Data is filteres. So if i just want to filter one of the Grids, i have to create two DomainDataSources. So i am not sure about any Alternatives or better Ways to get the Data.

    Thanks in Advance! 

    Wednesday, August 25, 2010 8:21 AM

Answers

  • The common pattern is one DDS per view. Like you've pointed out, this may lead to a proliferation of DDSs. Also, this may lead to redundant calls to the server. It's not necessary a bad pattern, just a less-than-optimal one. Loading with a DomainContext directly should give you more control over what data displayed and when, but you'll find the patterns you use (like MVVM) may be entirely different.

    Kyle

    Thursday, August 26, 2010 10:48 AM
  • Mostly like you were describing. One for all items, one for new items, one for items of type "A", one sorted by Date, one for the first page of data, etc.

    Kyle 

    Thursday, August 26, 2010 12:21 PM

All replies

  • The best way would be to migrate to a MVVM pattern or at least something similar.  That way you seperate your data calls from your UI.  You will be able to reuse a single data source for multiple UI components (ie datagrids). 

    A good place to start looking at MVVM is an intro video by Jesse Liberty here: http://www.silverlight.net/learn/videos/silverlight-4-videos/mvvm-introduction/

    Hope this helps.  Feel free to let me know if you have any questions.

    Tony

     

    Wednesday, August 25, 2010 10:02 AM
  • You're likely to get a range of opinions on this. There are definitely a number of people who prefer the MVVM pattern to using the DomainDataSource. On the other hand, there are some people who have been very successful using the DDS in their larger applications. If you're finding the DDS to be too difficult to use or test, you can directly load data using a DomainContext instead.

    Kyle

    Wednesday, August 25, 2010 10:13 AM
  • Thanks for your answers!

    I think i will have a look at the MVVM Pattern.

    @kylemc:

    I dont really think DDS is to difficult, i just dont know if it is ok to use like 20 DomainDataSources. For example in this scenario:

    I have a table and i need the whole table to be shown in a DataGrid. No Problem so i create a DomainDataSource.
    But i also want to get just the newest Dataset from the same table. So i create another Query in my DomainService getting just one and ordered by Date and get the Data with another DDS to my Client. 

    So i have a lot of DDSs and i am not sure if this is ok, or if i could do this a better way.

    If i would load the Data using ComainContext, i would probably store the Data in a Collection right? So to do the thinks in the scenario above,...i also would have to create a lot of collections. So all in all DDS and loading with DomainContext wuld make no difference??

    Thursday, August 26, 2010 2:53 AM
  • The common pattern is one DDS per view. Like you've pointed out, this may lead to a proliferation of DDSs. Also, this may lead to redundant calls to the server. It's not necessary a bad pattern, just a less-than-optimal one. Loading with a DomainContext directly should give you more control over what data displayed and when, but you'll find the patterns you use (like MVVM) may be entirely different.

    Kyle

    Thursday, August 26, 2010 10:48 AM
  • maybe a stupid question, but exactly do you mean by"one DDS per view"? :D 

    Thursday, August 26, 2010 11:07 AM
  • Mostly like you were describing. One for all items, one for new items, one for items of type "A", one sorted by Date, one for the first page of data, etc.

    Kyle 

    Thursday, August 26, 2010 12:21 PM
  • Have many people had issues with a 4004 error when debugging a silverlight application using DDS? I cannot get around an issue I am experiencing whereby Entity Data Model and domain Service created, connected to Service in SL application to fill datagrid but gives 4004 error each time the page is accessed.

    Thursday, August 26, 2010 12:26 PM
  • Not particularly. That's a pretty standard error that can occur for any number of different reasons. This post should help you get started investigating it.

    http://blogs.objectsharp.com/CS/blogs/dan/archive/2010/04/13/wcf-ria-services-not-found-error-message.aspx

    Kyle 

    Thursday, August 26, 2010 1:29 PM
  • Perhaps Kyle can correct me if I am wasting my time on this one, but...

    I've been creating a fairly large app using the DomainDataSource lately and what has worked very well for me has been to clean up the DDS as soon as it is no longer needed any more. They are so fast to load anyway that the users won't notice any difference. 

    So, then the user has navigated away from the screen with the grid that is attached to the DDS, I turn off "AutoLoad" and I clear the DDS. Then the next time the screen is navigated to, I reverse the process (well, I do a Load()).

    Doing this has also gotten rid of all the timeout problems I had been having before (I use Windows Authentication and was having problems when someone walked away from the application and went back to a page that had previously been visited).

    Rob

    Saturday, August 28, 2010 3:33 PM
  • I don't know if it's strictly necessary, but it's a reasonable approach. I'm not sure why it would fix your timeout issue, but I'm glad to hear it has. If you like how it's working now, there's no reason to change how you've done it.

    Kyle 

    Monday, August 30, 2010 10:27 AM