score:2
unless you go for simple classes (poco etc), your own implementation is likely to have nearly as much overhead as datatable
. personally, i'd look more at using tools like linq-to-sql, entity framework, etc. then you can use either linq-to-objects against local data, or the provider-specific implementation for complex database queries without pulling all the data to the client.
linq-to-objects can do all the things you mention, but it involves having all the data in memory. if you have non-trivial data, a database is recommended. sql server express edition would be a good starting point if you look at linq-to-sql or entity framework.
edited re comment:
regular tsql commands are fine and dandy, but you ask about the difference... the biggest being that linq-to-sql will provide the entire dal for you, which is a huge time saver, as well as making it possible to get a lot more compile-time safety. but is also allows you to use the same approach to look at your local objects and your database - for example, the following is valid c# 3.0 (except for [somedatasource], see below):
var qry = from row in [somedatasource]
group row by row.category into grp
select new {category = grp.key, count = grp.count(),
totalvalue = grp.sum(x=>x.value) };
foreach(var x in qry) {
console.writeline("{0}, {1}, {2}", x.category, x.count, x.totalvalue);
}
if [somedatasource] is local data, such as a list<t>
, this will execute locally; but if this is from your linq-to-sql data-context, it can build the appropriate tsql at the database server. this makes it possible to use a single query mechanism in your code (within the bounds of lola, of course).
score:0
why not use a local database like sqlserver ce or firebird embedded? (or even ms access! :)). store the data in the local database, do the processing using simple sql queries and pull the data back. much simpler and likely less overhead, plus you don't have to write all the logic for grouping/aggregates etc. as the database systems already have that logic built in, debugged and working.
score:0
yes, you can use linq to do all those things using your custom objects.
and i've noticed a lot of people suggest that you do this type of stuff in the database... but you never indicated where the database was coming from.
if the data is coming from the database then at the very least the filtering should probably happen there, unless you are doing something specialized (e.g. working from a cached set of data). and even then, if you are working with a significant amount of cached data, you might do well to put that data into an embedded database like sqlite, as someone else has already mentioned.
score:1
you'd be better off letting your database handle grouping, filtering and aggregation. datatables are actually relatively good at this sort of thing (their bad reputation seems to come primarily from inappropriate usage), but not as good as an actual database. moreover, without a lot of work on your part, i would put my money on the datatable's having better performance than your homegrown data structure.
Source: stackoverflow.com
Related Query
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- creating Linq to sqlite dbml from DbLinq source code
- Better code for avoiding one dictionary - Case Sensitivity Issue
- A Better DataTable
- Accessing a List multiple times in same code block - Any better approach?
- Is there a better way to get the column values from datatable
- source code for LINQ 101 samples
- How to code this LINQ query in a better way
- Is there a better way to code this LINQ fragment?
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Is there a better way to code this Duplicate ID Checker?
- Better Code in LinQ?
- Is there a better way to achieve this with Linq or a better code
- Better way to write this C# Code For List of Lists
- List or Array of String Contain specific word in Html Source Code
- Partition By Logic in Code to calculate value of a DataTable Column
- How to optimize a code using DataTable and Linq?
- c# Linq or code to extract groups from a single list of source data
- error :Could not find an implementation of query for source type datatable and join not found while trying to join two datatables
- LINQ query on a DataTable
- Is it better to call ToList() or ToArray() in LINQ queries?
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Is it better to use Enumerable.Empty<T>() as opposed to new List<T>() to initialize an IEnumerable<T>?
- Value cannot be null. Parameter name: source
- Filling a DataSet or a DataTable from a LINQ query result set
- Get all column names of a DataTable into string array using (LINQ/Predicate)
- How do I get a distinct, ordered list of names from a DataTable using LINQ?
- Linq code to select one item
More Query from same tag
- linq to sql join result
- Remove all records with opposite sign
- Creating DropDownLists from the detail for a grouped ViewModel
- Query to entity framework 7 using linq and related entities
- Linq get data from m to n tables?
- Find Min DateTime and Assign DateTime to Local Variable
- LINQ/Lambda equivalent to SQL NOT IN
- Get default value from a select in a query
- How do I quickly deserialize XML into a type?
- How to update column value using LINQ Query
- Use multiple ThenBy directly without any order
- Linq list subset removal
- Insert new XML node using LINQ
- How can i add linq query EnumerableRowCollection<TRow> to a datatable?
- Get list of child records
- Expression tree nested wheres
- Get unique pairings from dictionary object in .Net
- Finding user that have at least one tag object in linq?
- how to check for a value in the last 10 entries using linq to entities
- Collapse sub nodes to list using linq
- How can I build Linq query with dynamic OR statements?
- Remove non-constant duplicate words from strings in an array\list
- How can I add a record with a foreign key using entity framework?
- INCLUDE in Linq but to include only some columns from the included object
- OrderBy("it." + sort) -- Hard coding in LINQ to Entity framework?
- Return IGrouping of anonymous IEnumerable to present on DataGrid
- Split substring from string and count till next character
- Linq handling variable number of OrderBy
- ASP.NET LINQ Join won't work
- Which method is better for multiple join and left join by Linq?