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
Solved

Data Manipulation - Best way to process

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON  parse help 7 40
Dynamics CRM Plugin Query TotalRecordCount returning -1 13 44
Name Space error VS2015 1 25
reading excel file in .net 2 17
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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