Solved

Data Manipulation - Best way to process

Posted on 2009-04-10
5
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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