I have the following :
1) SQL Server in Backend Server:
tblCustomer ID CompanyName Group Product group GST -- ----------- ------- ------------- ---- 1 The One Exp A 4 2 The One Exp A 8 . . 20
2) SQLite-DB inside Tablet device.
tblCustomer ID CompanyName Group Product group GST -- ----------- ------- ------------- ---- 1 The One Exp A 4 2 The One Exp A 8 . The One . 20 The One
3) I use webservice to get the Data from the Server and insert records into SQLite Db using Sqlite-Net api using below Code
The Problems:
1). How to I update the tblCustomer in SQLite for changes below:
Note: ID in SQL sever and Sqlite ARE not the same.
ID CompanyName Group Product group GST
-- ----------- ------- ------------- ----
1 The One Exp A 6 < -- before it was 4
2) Someone add data in SQL Server and the total record is 21 now.
How to add this record in SQLite tbl customer?
foreach ( var client in Customers)
{
InsertNewCustomer(client.Company, client.Group, client.ProductGroup, client.GST)
}
private void InsertNewCustomer(string Company,string Grp, string PGrp, int Gst)
{
1) How to create SQL Statement for this case?
var existingCustomer = (db2.Table<Customer>().Where(c => c.No == Company)) ???
if (existingCustomer != null)
{
??-- how to handle?
int success = db2.Update(existingCustomer);
}
else
{
int success = db2.Insert(new Customer()
{
Name = Company,
Group = Grp,
ProductGroup = PGrp,
GST = Gst
});
}
}