lundi 12 octobre 2015

Save and update array in a SQL Database

I am trying to save an object (Customer) with an array of (Articles) named Sales to a database. Lets take a look at my tables:

Table Customers:

|ID|Name    |
-------------
| 1|Samuel  |
| 2|Michael |
| 3|Grace   |

Table Articles:

|ID|Name    |Price |
--------------------
| 1|Apple   | 1    |
| 2|Banana  | 5    |
| 3|Orange  | 2    |

Table Sales:

|CustomerID|ArticleID|
----------------------
|1         | 1       |
|1         | 2       |
|2         | 3       |

I know how to save the first time but if the array has changed (Eg. A sale was removed) I don't know how to update the Sales table.

How to update the table when the array has changed?

The programming language I use is C# with the System.Data.SQLite library but do not use Entity Framework right now.

I hope, you understand what I mean.

Aucun commentaire:

Enregistrer un commentaire