Solved

Data Manipulation - Best way to process

Posted on 2009-04-10
5
198 Views
Last Modified: 2013-12-17
Greetings all

I am relooking at the way I handle data - a recent discussion with a colleague left me wondering if my way was appropriate and what other, posisbly better ways were out there.

Currently I use  a Datalayer that extracts the data and then passes back a list of objects.

The List is then linked to the appropriate controls, where no updating is required. Where the data will be changed, I convert the List into a DataTable or DataSet and link to the Control. For updating I can use either a SQL Command object or pass back inidividual records to a stored procedure.

The plus, to me, of passing Lists is taht it allows complete separation of my DataLayer and presentation layer. As to converting to DataTable/DataSet - I've always done it liek that, but if there are better ways, I'm up for it.

Any thoughtd?


In advance, thanks!!

    allanmark
0
Comment
Question by:allanmark
  • 2
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 300 total points
ID: 24121038
the design looks good till the time you start converting it to a datatable or a data set
what is the requirement you are trying to do that
a generic list List<T> provides you with everything you need to perform as with the dataset or a datatable
0
 

Author Comment

by:allanmark
ID: 24121281
Thanks!

One common requirement is working with grdiView - insert, edit, etc.

If I understand what you are saying then whatever I do with a DataSet/Table (see  snippet example 1 and example 2 and example 3) I can do with a List, in addition to all else that the List offers me.

I've linked a list to the gridview and can browse through the data, etc. But if I delete the record via the gridview then I don't have a way to access the deleted record (see EG 2) or if  I want to check
record status (EG 3) and update if necessary,

EG 1:
 
DataRow newRow = dsBranches.Tables["Branches"].NewRow();
newRow["id"] = 0;
......
.....
dsBranches.Tables["Branches"].Rows.Add(newRow);
 
 
EG 2:
 
if (dsBranches.Tables["Branches"].Rows[rowIndex].RowState == 
    DataRowState.Deleted)
   .....
   ............
 
 
EG 3:
 
if (dsBranches.Tables["Branches"].Rows[rowIndex].RowState == 
    DataRowState.Modified)
   ProcessUpdate (..., ..., ...)
   ............

Open in new window

0
 
LVL 6

Expert Comment

by:hehdaddy
ID: 24122465
I would suggest dropping your object layer and return the data from the database as a DataSet, then bind to your controls. The changes are made to your DataSet, which are sent to the database.

The key is to remove the number of moving parts and take advantage of .NET's data handling.
0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 300 total points
ID: 24130214
eg 1 can be achieved by creating a new <T> object and then adding it to the list
List.Add(<T>)
create a unique id so that you can differentiate between newely added objects

eg 2: create a property for deleted (boolean) and just update it and while doing databind you can select non deleted objects only

eg 3: again add a property where you change a timestamp to find if something has been modified or not
0
 

Author Closing Comment

by:allanmark
ID: 31569107
Many thanks!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question