Questions tagged [linq-to-objects]

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

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.

For example, say that myCats is a list of Cat objects. Then you can pick your favorite cat by using:

Cat myFavorite = myCats.Single(c => c.Score == myCats.Max(x => x.Score));

To get an alphabetical listing of your cats, use this:

var listing = myCats.OrderBy(c => c.Name);

To get all cats that have caught more than 20 mice, use the following:

var champions = myCats.Where(c => c.MiceCaught.Count > 20);

You can also use a more SQL-like syntax:

var champions = from cat in myCats where cat.MiceCaught.Count > 20 select cat;

LINQ to Objects thus uses the same familiar syntax as the other LINQ implementations such as LINQ to Entities and LINQ to SQL.

1356 questions
-3
votes
1 answer

Using LINQ to sort and remove elements from a List

I'm trying to have LINQ sort a list then remove unnecessary items on it. class Item { public float time; public int level; public Item(int l, float t) { time = t; level = l; } } List items = new…
-4
votes
1 answer

Linq to objects - boondoggle?

I thought that LINQ to objects is great way for differed execution of joined data. In reality, it comes up as bad way to do things... Here is what we had, having few, few hundred, 3K and 3.5K records in a,b,c,d correspondingly IEnumerable
T.S.
  • 18,195
  • 11
  • 58
  • 78
-4
votes
3 answers

Setting the value to null using LINQ in list of list

I have a class public class ReceiptDisplayInfo { public string ReceiptItemFor{get;set;} public string ReceiptItemCategory{get;set;} public string ReceiptItemReference{get;set;} public string ReceiptRowCategory{get;set;} public string…
Piyush Sing
  • 45
  • 1
  • 9
-4
votes
1 answer

How to perform the below mentioned task(vb.net)?

Dim cells = From Qmaxminslist As DataGridViewRow In DataGridView2.Rows.Cast(Of DataGridViewRow)() Take Integer.Parse(daysamaxminsmv.Text) For Each row As DataGridViewRow In cells // piece of code... Next I have converted this code in C#…
-4
votes
1 answer

What is the difference between a LINQ subquery and a nested FROM statement

1) Subquery is a query within a query and as such must start with a FROM clause and end with SELECT or GROUP BY clause. But I'm puzzled why don't we also consider as a subquery those nested statements that only have a FROM clause ( thus they don't…
user1483278
  • 929
  • 1
  • 9
  • 17
-7
votes
3 answers

property remove from the list

Remove property from a list NorthwindDataContext db = new NorthwindDataContext(); List oList = new List(); oList = db.Categories.Select(p => new CategorySml { CategoryID = p.CategoryID, CategoryName…
shamim
  • 6,640
  • 20
  • 85
  • 151
1 2 3
90
91