Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, although ports exist for Java, PHP, JavaScript and ActionScript.
10
votes
4answers
758 views
Is linq more efficient than it appears on the surface?
If I write something like this:
var things = mythings
.Where(x => x.IsSomeValue)
.Where(y => y.IsSomeOtherValue)
Is this the same as:
var results1 = new List<Thing>();
...
2
votes
1answer
100 views
Using Dynamic LINQ to get a filter for my Web API
We are considering using the Dynamic.CS linq-sample included in the "Samples" directory of visual studio 2008 for our WebAPI project to allow clients to query our data.
The interface would be ...
3
votes
2answers
171 views
Extracting lambda expressions from linq queries and readability
Every now and then when I have a complex lambda, I do something like this:
Func<SomeObject, bool> equals = o =>
o.ID == someID && o.Name == someName && IsAdd || ...
var ...
6
votes
5answers
273 views
XSLT and possible alternatives [closed]
I had a look at XSLT for transforming one XML file into another one (HTML, etc.). Now while I see that there are benefits to XSLT (being a standardized and used tool) I am reluctant for a couple of ...
2
votes
4answers
142 views
Why should IQueryProvider implementations throw NotSupportedExceptions?
Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don't actually support the full IQueryable<T> interface, throwing ...
0
votes
1answer
222 views
Why is imperative programming preferred over functional programming? [closed]
Background: I am proponent of functional programming who works at a VB.NET shop where the prevailing mental model is imperative programming. Being that foundation of our system is WinForms I can ...
2
votes
1answer
203 views
Is it okay to convert dataset from stored procedure to IEnumerable
So, I am working on a project with a team and we are using Entity Framework. We basically want to use linq to entities, and not use stored procedures. I use quite a bit of lists and IEnumerables and ...
2
votes
2answers
209 views
Style for creating IEnumerable unions
There isn't any cool LINQ sugar for creating unions. The Enumerable.Union() method is usually called like this:
var bigList = list1.Union(list2);
The alternative is to call Enumerable.Union() which ...
11
votes
3answers
842 views
What problem domain is LINQ made for?
Each time I see a question posted on Stack Overflow on C#, I see at least one or two answers posted that solve a problem with LINQ. Usually people with very high reputation seem to use LINQ like pros.
...
2
votes
2answers
939 views
Is it better to create a stored procedure or entities to get to the data I need?
I just jumped into a new project with a new company using Entity Framework and ASP.NET MVC 4. I am no expert on Entity Framework, but I think I have a decent grasp of how to use it.
From what I can ...
36
votes
5answers
7k views
for vs. foreach vs. LINQ
When I write code in Visual Studio, ReSharper (God bless it!) often suggests me to change my old-school for loop in the more compact foreach form.
And often, when I accept this change, ReSharper goes ...
3
votes
1answer
224 views
Algorithm to optimize grouping
I would like to know if there's a known algorithm or best practice way to do the following:
I have a collection with a subcollection, for example:
R1 R2 R3
-- -- --
M M M
N N
L L
A
What i ...
3
votes
5answers
238 views
Using 'new' in a projection?
I wish to project a collection from one type (Something) to another type (SomethingElse). Yes, this is a very open-eneded question, but which of the two options below do you prefer?
Creating a new ...
2
votes
1answer
1k views
Nesting Linq-to-Objects query within Linq-to-Entities query –what is happening under the covers?
var numbers = new int[] { 1, 2, 3, 4, 5 };
var contacts = from c in context.Contacts
where c.ContactID == numbers.Max() | c.ContactID == numbers.FirstOrDefault()
...
2
votes
1answer
158 views
Are elements returned by Linq-to-Entities query streamed from the DB one at the time or are they retrieved all at once?
Are elements returned by Linq-to-Entities query streamed from the database one at the time ( as they are requested ) or are they retrieved all at once:
SampleContext context = new ...