TableSynchronizer will synchronize data between and ITable instances, new rows in the source will be added to the destination, existing rows in both will be updated in destination, and rows that exist only in destination will be deleted.
You can use TableSynchronizer to synchronize data between feature classes from different workspaces, Feature Layers, Tables ...
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using EAGL.Data;
6 using ESRI.ArcGIS.Geodatabase;
7 using EAGL.Core;
8
9 namespace ClientTests
10 {
11 class Program
12 {
13 static void Sync()
14 {
15 // init lic
16 SecurityHelper.Init();
17 // get the workspace
18 WorkspaceInfo wsInfo = new WorkspaceInfo(WorkspaceType.ACCESS);
19 wsInfo.Database = @"d:\data.mdb";
20 WorkspaceManager wsm = new WorkspaceManager(wsInfo);
21 IWorkspace workspace = wsm.GetWorkspace();
22 IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
23
24 // open feature classes
25 IFeatureClass fc1 = featureWorkspace.OpenFeatureClass("src");
26 IFeatureClass fc2 = featureWorkspace.OpenFeatureClass("des");
27
28 // create Table synchronizer
29 TableSynchronizer tsync = new TableSynchronizer(
30 (ITable)fc1, (ITable)fc2, "WELL_NAME", "WELL_NAME");
31 SyncResult result = tsync.Synchronize();
32 Console.WriteLine(
33 "{0} rows added, {1} rows updated, {2} rows deleted",
34 result.InsertCount, result.UpdateCount, result.DeleteCount);
35
36 }
37
38
39 static void Main(string[] args)
40 {
41 Sync();
42 }
43 }
44 }
SyncResult will hold how many rows were inserted, updated or deleted from the destination table.
Regards.
No comments:
Post a Comment