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.
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.
- Client1 and Client2 are connected and working at the same time
- Client1 made changes and run context.CommitChanges()
- 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?