score:9
i assume that datatable.select
needs even more memory than enumerable.where
since the latter is just a loop on the datarowcollection
of the datatable
whereas the old datatable.select
creates new objects like select
or dataexpression
and it even returns new objects(datarow[]
) from the query. enumerable.where
just uses a predicate in a loop to determine what to return. it's also executed lazily, so you could just take, say 10 rows from the result.
var rows = dt.asenumerable()
.where(row => row.field<int>("id") == 2)
.take(10); // not possible with datatable.select
both are in-memory queries, so there's not a great difference.
i would chose what is more readable, powerful and maintanable and also strongly typed(field
extensions): linq-to-datatable
.
score:3
i suggest you to go through asp.net forum thread - datatable.select vs datatable.asenumerable().firstordefault
from: which one to use; datatable.select() or linq?
linq is generally easier to read, on my opinion, than pretty much any other form of data filtering and has the advantage over using datatable.select of being, at least partially, strongly-typed making it harder to make mistakes.
linq is faster than select for large number of rows, when rows keep increasing, you should see considerable difference.
Source: stackoverflow.com
Related Query
- How I can filter a dataTable with Linq to datatable?
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- I need to compare list with Datatable and filter values using Linq
- How do I use LINQ to filter a datatable against a Lst of strings that need to be split?
- Filter Datatable with linq by considering deleted rows
- source code for LINQ 101 samples
- LINQ to DataTable Results Filtering
- filtering a collection using Linq - how to reuse the same filter
- I need to filter distinct value from datatable using IEnumerable LINQ
- Filter datatable with Linq by a decimal list in c#
- filtering out null values while converting datatable to dictionary using linq
- LINQ filter Datatable by n Columns
- filtering a DataTable using LINQ
- Simple linq question: How to filter a source afterwards?
- datatable to datatable linq filter
- LINQ filtering based on preview filter
- c# Linq or code to extract groups from a single list of source data
- Linq - Filter datatable based on other datatable column values
- How to filter DataTable with LINQ
- Filtering DataTable with LINQ
- How to use LINQ filter on a DataTable in Uipath
- Issue with filtering DataTable using LINQ
- Filter Datatable dynamic/multiple condition using linq or c#?
- How Filter Binding Source Connected To linq Query
- LINQ query on a DataTable
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Filling a DataSet or a DataTable from a LINQ query result set
- Linq code to select one item
More Query from same tag
- LINQ to Entities does not recognize the method (Trying to get Previous and Next record)
- How to extract conditional statements from linq query?
- linq sum in vb.net
- Unknown column 'Project1.ID' in 'where clause'
- Check specific values in an array
- restrict objects based on count of sub list in LINQ
- Query for all nested XML types in LINQ
- ASP.NET Sum a column returned from stored procedure in LINQ
- Manually select related table data (SELECT N + 1 problem) LINQ to SQL
- Return a List<int> from List<T> with an integer property?
- Unique Values from a list of of items in C#
- linq vs ToDictionary() and TryGetValue() - what is more efficient?
- C# List<T> OrderBy float member
- LINQ Expression optimization
- c# linq search an EntityObject values from an IQueryable list
- JSON Where clause filter using Newtonsoft.Json.Linq
- Convert DateTime format to MMMM yyyy, dd using lambda expression
- C# - Ternary operator between Dictionary and Object[]
- Object reference not set to an instance of an object in LINQ C#
- Serializing IQueryable<T> to session state server
- EntityFramework: Add Where clause to ObjectSet Query to Select on CHILD attributes
- Join few tables without repeat same data
- Combine Multiple Linq Expressions
- Join multilevel relationship in LINQ to SQL
- How to return either all properties or a selection of it in C# using LINQ?
- How to do LINQ Cross Join With Dot Notation
- Implementing where clause in LINQ with join
- ObjectContext Closed error when using Include?
- Creating database using DataContext and System.Data.SQLite in C#
- Using Linq to find array with the largest length