Top "Linq-to-objects" questions

The term "LINQ to Objects" refers to the use of LINQ queries with any IEnumerable or IEnumerable<T> collection directly, without the use of an intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML.

Linq OrderBy against specific values

Is there a way in Linq to do an OrderBy against a set of values (strings in this case) without …

c# linq linq-to-objects
Why does LINQ query throw an exception when I attempt to get a count of a type

public readonly IEnumerable<string> PeriodToSelect = new string[] { "MONTH" }; var dataCollection = from p in somedata from h in p.…

c# linq exception-handling linq-to-objects
How to debug a LINQ Statement

I have a Linq to objects statement var confirm = from l in lines.Lines where (l.LineNumber == startline.LineNumber) || (l.…

linq debugging linq-to-objects
LINQ SelectMany and Where extension method ignoring nulls

I have the below example code, and I am interested to know how I can make this any cleaner, possibly …

c# linq .net-4.0 linq-to-objects
Joining three tables and using a left outer join

I have three tables. Two of them join equally but one will need to join with a left. I'm finding …

linq linq-to-entities linq-to-objects
LINQ to Objects Join two collections to set values in the first collection

I have the following Entity Framework query: var results = from r in db.Results select r; I'm using AutoMapper to …

c# .net linq-to-objects
Use LINQ and C# to make a new List from an old List

This should be pretty simple, but I am new at LINQ. I have a List<FillStruct> of FillList …

c# linq linq-to-objects
Using LINQ to Objects to find items in one collection that do not match another

I want to find all items in one collection that do not match another collection. The collections are not of …

c# linq linq-to-objects
Linq Except with custom IEqualityComparer

I am trying to find the difference between two generic lists, as in the example below. Even though t1 and …

c# linq-to-objects iequalitycomparer
"Nested foreach" vs "lambda/linq query" performance(LINQ-to-Objects)

In performance point of view what should you use "Nested foreach's" or "lambda/linq queries"?

c# lambda foreach linq-to-objects