ConflictResolver は次のとおりです。
csp.ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.ClientWins;
csp.ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ClientWins;
クライアントの更新とサーバーの更新の場合、またはクライアントの更新とサーバーの削除の場合。btnSynボタンを押すたびにサーバーが勝ちますが、クライアントに勝ちたいです。
教えてください。
private void LoadData()
{
//dataGridView1.DataSource = ctx.Employees;
ctx.Refresh(System.Data.Objects.RefreshMode.ClientWins, ctx.Employees);
dataGridView1.DataSource = null;
dataGridView1.DataSource = ctx.Employees;
}
private void btnSave_Click(object sender, EventArgs e)
{
ctx.SaveChanges();
}
private void btnRefresh_Click(object sender, EventArgs e)
{
LoadData();
}
private void btnSync_Click(object sender, EventArgs e)
{
TaskTrackerDataEntityCacheSyncAgent syncAgent = new TaskTrackerDataEntityCacheSyncAgent();
syncAgent.Employees.SyncDirection = SyncDirection.Bidirectional;
var syncStats = syncAgent.Synchronize();
TaskTrackerDataEntityCacheClientSyncProvider csp = new TaskTrackerDataEntityCacheClientSyncProvider();
csp.ConflictResolver.ClientDeleteServerUpdateAction = ResolveAction.ServerWins;
csp.ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.ClientWins;
csp.ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ClientWins;
MessageBox.Show(String.Format("Uploaded/Downloaded: {0}/{1}{4}Uploads/Downloads Failed: {2}/{3}{4}", syncStats.TotalChangesUploaded, syncStats.TotalChangesDownloaded, syncStats.UploadChangesFailed, syncStats.DownloadChangesFailed, Environment.NewLine));
LoadData();
}