SyncFramework: How to sync all columns from a table?

佐手、 提交于 2019-12-11 12:56:52

问题


I create a program to sync tables between 2 databases.

I use this common code:

DbSyncScopeDescription myScope = new DbSyncScopeDescription("myscope");
DbSyncTableDescription tblDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Table", onPremiseConn);
myScope.Tables.Add(tblDesc);

My program creates the tracking table only with Primary Key (id column). The sync is ok to delete and insert rows. But updating don't. I need update all the columns and they are not updated (For example: a telephone column).

I read that I need to add the columns I want to sync MANUALLY with this code:

Collection<string> includeColumns = new Collection<string>();
includeColumns.Add("telephone");
...
includeColumns.Add(Last column);

And changing the table descripcion in this way:

DbSyncTableDescription tblDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Table", includeColumns, onPremiseConn);

Is there a way to add all the columns of the table automatically? Something like:

Collection<string> includeColumns = GetAllColums("Table");

Thanks,


回答1:


SqlSyncDescriptionBuilder.GetDescriptionForTable("Table", onPremiseConn) will include all the columns of the table already.

the tracking tables only stores the PK and filter columns and some Sync Fx specific columns.

the tracking is at row level, not column level.

during sync, the tracking table and its base table are joined to get the row to be synched.



来源:https://stackoverflow.com/questions/21344046/syncframework-how-to-sync-all-columns-from-a-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!