score:4
Accepted answer
var columns = table.rows.cast<datarow>()
.selectmany(row => table.columns.cast<datacolumn>(), (row, column) => new { row, column })
.where(pair => pair.column.datatype == typeof(string) && !pair.row.isnull(pair.column))
.groupby(pair => pair.column.columnname, (key, items) => new
{
columnname = key,
maxlength = items.max(x => ((string)x.row[x.column]).length)
});
score:1
var columnnames = from column in table.columns.cast<datacolumn>()
select new { column.columnname, column.maxlength };
Source: stackoverflow.com
Related Query
- In a DataTable object, how can I get a list of columns and their min/max string.Length?
- How can I get totals for more than one column in a list and put this into an object using LINQ?
- How can I get LINQ to return the object which has the max value for a given property?
- How to get Max String Length in every Column of a Datatable
- How can I get LINQ to return the index of the object which has the max value in a collection?
- How to use a LINQ in order to remove Min and Max value in List
- How can I get the top three players and their high scores from a collection using linq and lambdas
- How can I flatten out data in a list and then get a count of what's in each column using LINQ?
- How to check if an item exists in a string List and if it exists, get its index
- Using Linq how do get a list of users and their last login from two tables
- How to get the property from a list of object that is a string with the lowest numeric value
- How to use a LINQ : If there are several min and max values, just remove only one min and max value in List
- Quering a Dynamic Object List for Max and Min Values
- How to get a list of parents and children depending on the value of their children in Linq?
- How to find string in Dictionary list and get its pair integer value
- How to get index of string found in list and equal to input string
- How can I filter the elements in the list by certain criteria and then change their properties with Linq?
- How do I get list of object property names and values in C#?
- How can I select from an included entity in LINQ and get a flat list similar to a SQL Join would give?
- How can I get EF to Select and only return selected columns
- How get max count with min key from list integer with linq written in one expression
- How can I get a list of DirectoryInfo where the name of the directories contains a string stored in a List<string>?
- How can I get more than one property from an object list to an array?
- How to get a an object in list with min field value using linq?
- How to get the list of employees and their reporting level recursively using LINQ
- How to get Max and Min IN/OUT time for each date in LINQ?
- how to get a list of item in object from another table using linq and entity framework in C#?
- How can I link two classes, select and still get a list output using Entity Framework and LINQ?
- How can we get list of two column say firstname and lastname from customer table in mvc using linq query
- How to get the min and max value from a dbcontext
More Query from same tag
- C# re-use LINQ expression for different properties with same type
- LINQ Zip all elements
- Query with Nest field boosting returning no results from Elasticsearch
- LINQ C# Sum and changing value to time (hh:mm:ss) in datatable
- How do I get the first value from this collection using Linq to Entities?
- Entity Framework 6 and is null
- XDocument containing namespaces
- Remove Parents that are children in the same Object using Linq
- Linq - Rows In Database not Deleting
- Can I add numerically the values of two arrays using LINQ?
- How to implement SelectMany in System.Linq.Dynamic ExpressionParser
- Combining Linq Expressions for Dto Selector
- How to read data from large multiple excel worksheets in to a list using C#
- How to convert nested object from one type to another
- Repository pattern with "modern" data access strategies
- Find in text with Linq
- How to perform a Linq match on a single item without ToArray()
- LINQ group by and filter particular record
- C# Functions to accept arguments from XML
- How to compare 2 datatables without any loops and key relationships in c# or linq
- Performing a wildcard search
- LINQ statement no longer works after being wrapped into an extension method
- How to check if column is exist in Linq join query c#?
- How to call a method in the where clause of a LINQ query on a IQueryable object
- to avoid reading an rss node that is not present in the feed
- How to get the newly created object inside the .Select() in a LINQ Query
- How to get child element value in XML using LINQ
- Return parent record with only children that meet a certain criteria
- Linq join time error
- Splitting words based on the occurrence of capital letter