locked
General Question about DomainDataSource RRS feed

  • Question

  • Hi,

    i have a SQL Server table and with Ado.Net Entity Data Model and DomainService i get the Data to my Client.
    So in my Silverlight Application i have DomainDataSources that represent the Data from the table, is that right?

    So if Bind a DataGrid to that DomainDataSource, the Data is shown in my DataGrid.

    Now my Questions:

    1. The Data in the DataGrid is shown all the time, does that mean i have all the time a connection to my SQLServer Database?

    2. How can i achieve that the Data is only shown if i click a specific Button? At the moment i am using FilterDescriptors for that, is that the only way?

    Thursday, August 5, 2010 10:16 AM

Answers

  • Why can you run it and see what is happening?

    When you changed the filter and calling load again, the new data should replace the old data.

    Monday, August 9, 2010 10:18 AM

All replies

  • 1. The Data in the DataGrid is shown all the time, does that mean i have all the time a connection to my SQLServer Database?

    No, you do not have connection to your server all the time. DomainDataSource has load function. When it is called (if you set AutoLoad=True, it will be called when you load your page), it will start a a-sync call back to Server to load the Data back.  When the Load is completed, the data is returned to client side and cached in DomainDataSource object. So you have the data displayed in your UI control.  

    2. How can i achieve that the Data is only shown if i click a specific Button? At the moment i am using FilterDescriptors for that, is that the only way?

    Set AutoLoad = "False" on the DomainDataSource. Call DomainDataSource.Load when you click the button.



    Thursday, August 5, 2010 10:32 AM
  • Thanks for the Reply, that helped.

    So if i create a FilterDescriptor in Code and Filter my DomainDataSource, i only Filter the Client Data?
    Or is the Data loaded again, when i Filter and delete the Filter? 

    Thursday, August 5, 2010 11:19 AM
  • you only filter the client data. Domaindatasource is dataset if you want to work with dynamic data you should use PagedCollectionview more fucntuion.  

    Thursday, August 5, 2010 11:24 AM
  • Ok, so where is the difference if i use DomainDataSource or load the Data like this:

    dc is my DomainService Class:

    dc.Load(dc.GetWasserprovinzensQuery()).Completed += new EventHandler(Neues_Event);


     

    Thursday, August 5, 2010 11:41 AM
  • you only filter the client data. Domaindatasource is dataset if you want to work with dynamic data you should use PagedCollectionview more fucntuion.

     

    No. If you set Domaindatasource.FilterDescriptors, the filter is applyed to the Query before it sent back to Server. So the Filter is applied in your final SQL. You can you use SQL profiler to monitor the SQL executed in SQL Server to understand this.

    If you use PagedCollectionView, the Filter is applied on client data after the data is returned.


    Thursday, August 5, 2010 2:19 PM

  • Ok, so where is the difference if i use DomainDataSource or load the Data like this:

    dc is my DomainService Class:

    dc.Load(dc.GetWasserprovinzensQuery()).Completed += new EventHandler(Neues_Event);


    Do not pass the query in dc.Load, set the QueryName on the dc if you want to pass the Filtered query back.  If you pass the Query to the Load function. It will just use this original query.

    Just call dc.Load();

    The real query passed back would be like this:

    var q = dc.GetWasserprovinzensQuery(); // You base query

    q = q.Where(...);  // Modify the query with your filter

    dc.Load(q); // Load with this query

    But DomainDataSource will do these for you when you all dc.Load(), so you don't have to do anything.

    If you need to catch LoadComplete call back event, you can add LoadedData event on the DomainDataSource.




    Thursday, August 5, 2010 2:27 PM
  • So now i have to DomainDataSource with a FilterDescriptor and AutoLoad=False.

    If i click a Button the Data (Only the Filtered Data) is loaded to my Client, right?

    What if i change the Filter Value and Filter for a different Value, what happens to the before loaded Data? 

    Monday, August 9, 2010 6:58 AM
  • Why can you run it and see what is happening?

    When you changed the filter and calling load again, the new data should replace the old data.

    Monday, August 9, 2010 10:18 AM