A Few questions on tables, filter, etc #792
Replies: 1 comment
-
The tables definition is contained in the This definition is downloaded by the client each time a sync is starting. For example: services.AddControllers();
services.AddDistributedMemoryCache();
services.AddSession(options => options.IdleTimeout = TimeSpan.FromMinutes(30));
// Create the setup used for your sync process
var tables = new string[] {"ProductCategory",
"ProductModel", "Product",
"Address", "Customer", "CustomerAddress",
"SalesOrderHeader", "SalesOrderDetail" };
var setup = new SyncSetup(tables)
{
// optional :
StoredProceduresPrefix = "s",
StoredProceduresSuffix = "",
TrackingTablesPrefix = "s",
TrackingTablesSuffix = ""
};
services.AddSyncServer<SqlSyncProvider>(connectionString, setup, options);
The definition of the filter and the parameters are placed on the server side, in the Definition is:
// Here we have a filter on Address with 2 parameters
var addressFilter = new SetupFilter("Address");
addressFilter.AddParameter("City", "Address", true);
addressFilter.AddParameter("postal", DbType.String, true, null, 20);
addressFilter.AddWhere("City", "Address", "City");
addressFilter.AddWhere("PostalCode", "Address", "postal");
setup.Filters.Add(addressFilter);
services.AddSyncServer<SqlSyncProvider>(connectionString, setup, options); The values of the parameters are coming from each client, on the client side: var serverOrchestrator = new WebRemoteOrchestrator("https://localhost:44342/api/sync");
var clientProvider = new SqlSyncProvider(clientConnectionString);
var agent = new SyncAgent(clientProvider, serverOrchestrator, options);
var parameters = new SyncParameters
{
{ "City", "Toronto" },
// Because I've specified that "postal" could be null,
// I can set the value to DBNull.Value (and the get all postal code in Toronto city)
{ "postal", DBNull.Value }
};
// Launch the sync process
var s1 = await agent.SynchronizeAsync(progress);
// Write results
Console.WriteLine(s1);
See previous answers
They are embedded in the JSON payload on each call |
Beta Was this translation helpful? Give feedback.
-
I have some questions about the tables:
Beta Was this translation helpful? Give feedback.
All reactions