public void InsertClient(ClientViewModel clientViewModel) { ClientTable table = ClientTable.Create(clientViewModel); TableQuery <ClientTable> query = connection.Table <ClientTable>().Where(cli => cli.UniqueHash.Equals(table.UniqueHash)); if (clientViewModel.ClientSocket != null && clientViewModel.ClientTable != null) { table.InTraffic = clientViewModel.ClientTable.InTraffic + clientViewModel.ClientSocket.InTraffic; table.OutTraffic = clientViewModel.ClientTable.OutTraffic + clientViewModel.ClientSocket.OutTraffic; } if (query.Count() > 0) { this.connection.Update(table); } else { this.connection.Insert(table); } }