This is a migrated thread and some comments may be shown as answers.

Synchronize DomainContext in multiple clients

1 Answer 62 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jacek
Top achievements
Rank 1
Jacek asked on 25 Jan 2013, 09:40 AM

I am designing application in Silverlight 5 with WCF RIA Services and Telerik OA ORM.

I can not find a way to automatically refresh the data for all clients currently connected.

I show this on example

This is grid where I binding data:

<sdk:DataGrid AutoGenerateColumns="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" x:Name="grid">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTextColumn MinWidth="79" Header="ID" IsReadOnly="True" Binding="{Binding Id}"  />
        <sdk:DataGridTextColumn MinWidth="150" Header="Name" Binding="{Binding User_name}"  />
    </sdk:DataGrid.Columns>
 </sdk:DataGrid>


This is fragment code-behind


private DomainContext context = new DomainContext();
 
private function void LoadContractors()
{
    LoadOperation<Contractor> contractors = context.Load<Contractor>(context.GetContractorsQuery());
    contractors.Completed += (s, args) =>
       {
        grid.ItemsSource = contractors.Entities;
        };
}

Problems begin when more than one client is connected.

  1. Client1 and Client2 are connected and working at the same time
  2. Client1 made changes and run context.CommitChanges()
  3. Client2 doesn't see the changes. If the Client2 will be edited the same record like Client1, he will receive an error:

Submit operation failed due to conflicts. Please inspect Entity.EntityConfilct for each entity in EntitiesInError for more information

To solve this problem I created buttonRefresh, When the error occurs Client must load new data.

private function void RefreshContractors()
{
    this.context = new DomainContext();
    LoadContractors();
}

My question is:

Is there another solution, so that after editing the data in one client, changes immediately appear in another client? Is it possible to set OpenAcces to synchronize contexts for clients or if not, can all clients work in the same DomainContext?

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 28 Jan 2013, 04:55 PM
Hi Jacek,

I am afraid that you need to implement custom handling for syncing the data in your Silverlight application. Actually you could find this blog post helpful. It demonstrates how to handle similar scenario.

Hope that helps.


All the best,
Damyan Bogoev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Tags
Web Services
Asked by
Jacek
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or