Solved

Data Manipulation - Best way to process

Posted on 2009-04-10
5
195 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now