服务器:
CREATE TABLE [dbo].[Patient](
[GuidClient] [uniqueidentifier] NOT NULL,
[IdClient] [int] NOT NULL,
PRIMARY KEY NONCLUSTERED
(
[IdClient] ASC,
[GuidClient] ASC
)
客户端:
CREATE TABLE [Patient] (
[Id] int NOT NULL IDENTITY PRIMARY KEY,
[GuidClient] [uniqueidentifier] -- this always null, for Sync Framework
)
从客户端下载到服务器时,我将实际值设置为GuidClient列:
remote.ChangesSelected += (s, e) =>
{
if (e.Context.DataSet.Tables.Contains(patTbl))
{
var dataTable = e.Context.DataSet.Tables[patTbl];
for (int j = 0; j < dataTable.Rows.Count; j++)
{
DataRow row = dataTable.Rows[j];
row["GuidClient"] = clientGuid;
}
}
}
问题1:如果我们需要在服务器上删除,如何处理删除?因为服务器上的GuidClient是PK,我们需要将值设置为GuidClient列,因为我理解515错误(无法将值NULL插入列...)。像
这样的东西row.RejectChanges();
row["GuidClient"] = clientGuid;
row.Delete();
问题2:这个模式带有&#34;虚拟&#34; PK无法从服务器下载更改到客户端,对吗?