Skip to main content

Questions tagged [linq]

Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. Please consider using more detailed tags when appropriate, for example [linq-to-sql], [linq-to-entities] / [entity-framework], or [plinq]

20 votes
5 answers
35k views

Generic LINQ query predicate?

Not sure if this is possible or if I'm expressing correctly what I'm looking for, but I have the following piece of code in my library repeatedly and would like to practice some DRY. I have set of ...
Codewerks's user avatar
  • 5,934
2 votes
1 answer
294 views

Query to retrieve names of group nodes

If I had some XML such as this loaded into an XDocument object: <Root> <GroupA> <Item attrib1="aaa" attrib2="000" /> </GroupA> <GroupB> <...
Bullines's user avatar
  • 5,686
22 votes
5 answers
14k views

How do I avoid a memory leak with LINQ-To-SQL?

I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows Service to do some processing, and I'm looping through a large amount of data that I'm pulling back from ...
Sam Schutte's user avatar
  • 6,716
46 votes
0 answers
27k views

What is the LINQ way to implode/join a string array? [duplicate]

I have the following string array: var sa = new string[] {"yabba","dabba","doo"}; I can convert it to "yabba, dabba, doo" it using string.Join() but what is the super-cool LINQ way of doing it? The ...
George Mauer's user avatar
8 votes
14 answers
926 views

How do I write this in Ruby/Python? Or, can you translate my LINQ to Ruby/Python?

Yesterday, I asked this question and never really got an answer I was really happy with. I really would like to know how to generate a list of N unique random numbers using a functional language such ...
Esteban Araya's user avatar
42 votes
10 answers
48k views

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.LineNumber == endline.LineNumber) select l; The confirm object is ...
johnc's user avatar
  • 40k
5 votes
6 answers
8k views

Can you do LINQ-like queries in a language like Python or Boo?

Take this simple C# LINQ query, and imagine that db.Numbers is an SQL table with one column Number: var result = from n in db.Numbers where n.Number < 5 select n.Number; This ...
apenwarr's user avatar
  • 11k
10 votes
12 answers
2k views

Getting started using Linq, what do I need?

Basically what the title says. (Forgive me because I am a .NET newb) In my department, we have a server running .net 3.5 and ever since I got into this section I have been using LINQ. However, I am ...
Mike Fielden's user avatar
  • 10.1k
2 votes
3 answers
2k views

Linq to SQL Grouping Child Relationships

I'm trying to run a LINQ to SQL query that returns a result in a grid view in a search engine style listing. In the simplified example below, is it possible to populate the collection with a comma-...
Jonathan S.'s user avatar
  • 5,877
9 votes
7 answers
6k views

How fast is LINQ?

I need to manipulate 100,000 - 200,000 records. I am thinking of using LINQ (to SQL) to do this. I know from experience that filtering dataviews is very slow. So how quick is LINQ? Can you please ...
ThatBloke's user avatar
  • 513
14 votes
2 answers
8k views

Design Patterns using IQueryable<T>

With the introduction of .NET 3.5 and the IQueryable<T> interface, new patterns will emerge. While I have seen a number of implementations of the Specification pattern, I have not seen many ...
Brad Leach's user avatar
14 votes
6 answers
27k views

Dynamic LINQ and Dynamic Lambda expressions?

What is the best way of dynamically writing LINQ queries and Lambda expressions? I am thinking of applications where the end user can design business logic rules, which then must be executed. I am ...
Sklivvz's user avatar
  • 30.9k
190 votes
3 answers
115k views

Can I return the 'id' field after a LINQ insert?

When I enter an object into the DB with Linq-to-SQL can I get the id that I just inserted without making another db call? I am assuming this is pretty easy, I just don't know how.
naspinski's user avatar
  • 34.5k
18 votes
6 answers
21k views

LINQ to entities - Building where clauses to test collections within a many to many relationship

So, I am using the Linq entity framework. I have 2 entities: Content and Tag. They are in a many-to-many relationship with one another. Content can have many Tags and Tag can have many Contents. So I ...
Phobis's user avatar
  • 7,694
6 votes
5 answers
4k views

linq equivalent of 'select *' sql for generic function?

I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the ...
Nick's user avatar
  • 5,656

15 30 50 per page