dimanche 4 décembre 2016

Table Data Gateway and Table Module in C#

I am trying to use patterns to develop a three tier application and I am stuck with some basic questions about implementation. The idea is get data from a database store them into a dataset and provide that dataset to domain model to do changes and passing it to presentation. The problem is I really do not understand how to work with retrieved data.

Let's say I have a database table orders with columns userID / order / status.

My gateway looks like

public class orderGW {
private DataSet ds = new DataSet();
public DataSet SelectOrdersForUser(int id){
...
do sql query and get data from database to SqlAdapter
Adapter.Fill(ds,"orders");
return ds;
}

... other methods to retrieve data for given select and storing them into dataset as "orders" table...

}

What if two different users would like to retrieve data. User which ask for data as the second one will overwrite data for the first one, so when the first one do some changes and try to update to db it won't be possible? I can do some check like

if(this table name in dataset){
don't reload/refresh it}

but in that case the system will be only for one user at time I think. I have read M.Folwer description of that pattern but I have not found any simple implementation example. Do you know how to solve aforementioned issue or do you have some example which can help me to solve this?

Aucun commentaire:

Enregistrer un commentaire