2

I'm currently working on a fund project and I have it set up so I get the holdings from my database and store in in to a DataTable to process.

I've created a function where my Database results are returned as a DataTable

var dtAll = db.GetTable(query)

Since a group of accounts have the same holding ie: MSFT, AAPL you will not get the same information twice only once. then apply the information to all the holdings.

My question is it worth it to instead of breaking it down into objects by creating a class List of accounts - > Fund - > holding

or going through LINQ

Additional information the actual DB table has everything listing on the holding level with the account coded in the record line (this is how the original set up was before I started at the company)

so it be like

accountx date MSFT 30 100 ...

accountz date MSFT 30 120 ...

the process is performing a lot of calculations and data manipulation

  • 2
    It's not clear what you are asking here. The prima facie answer to your question appears to be "it depends." – Robert Harvey Mar 14 '16 at 19:59
  • I'm doing a lot of data processing and calculation before inserting it back in to the database. – Philip Mar 14 '16 at 20:02
  • If that's the case, you probably could skip the application specific objects. Just try not to duplicate business logic in several places. – Berin Loritsch Mar 14 '16 at 20:06
  • I've broken the business logic into a DLL depending on the type of account will perform the specific operations ie : Fund vs benchmark – Philip Mar 14 '16 at 20:09
  • I have a junior coworker who used a DataTable as a collection object in a small project. The data didn't even come from a database, it came from a file. He did all of his work with the data by accessing DataRows in the DataTable and typing out column names. Ugh .. what a mess. I told him not to do that again. If I had time, I'd work with him to create something better. – user2023861 Jun 17 '16 at 13:05
2

Data table/Data sets are a generic type of object. One will have to write more code to retrieve and set information in a data table. It's also a very heavy object as opposed to a POCO.

For example: DataTable.table[0].rows[0] etc....

Now consider a list of Funds. Lightweight and specific.

var funds = GetFundsFromRepository();
var total;
for each (fund in funds)
{
   total += fund.Amount;
} 

It's easier for one to see what is going on as opposed to using a Data table. It's also easier to test as we just have to new up a List of Funds as opposed to creating a data table, populating tables, records, rows, columns, etc.

One can use either.

However, I prefer the latter as a data table is not a domain specific object. A Fund is a domain specific object and may make it easier for others to understand the logic involved with your application.

  • It was my first Idea, the DataTables are taking a huge performance hit. because I need to convert a lot of things back and forth from numerical and string. the only major re-haul I see from an object is creating all the members of the class (there is like 60 and can grow) its the nature of financial applications but then again you can get defaults and better validation, also I can use LINQ to SQL after to map it to the table. – Philip Mar 14 '16 at 20:45
0

The biggest disadvantage of a Data-table is no fixed structure and zero help from IDE. A fellow developer will never know what all columns are present in your datatable unless they apply a break point or have access to the database. Always assume someone else will have to maintain your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.