0
votes
1answer
92 views

Simplifying data search using .NET

An example on the asp.net site has an example of using Linq to create a search feature on a Music album site using MVC. The code looks like this - public ActionResult Index(string movieGenre, string ...
0
votes
2answers
199 views

foreach in list or foreach in list.where [duplicate]

I don't know what to call this question. This is my example: foreach (var item in lstItem.Where(item => stock.ItemCode == item.ItemCode)) { stock.ItemName = item.ItemName; ...
1
vote
2answers
162 views

TDD - Making assertions about C# Expression trees

How would you unit test the PerformUpdate method in the sample below? This is a (very) simplified version of some code that performs updates against a database where the schema is dynamic and ...
2
votes
3answers
569 views

Optimal way to implement this specific lookup table in C#?

I want to create a lookup table for this data: The "input variables" (what is used to "lookup") are 4 different doubles that can each take on 1 of 200 numbers (the numbers range from 1-1000 but there ...
3
votes
1answer
293 views

which sorting algorithms is using OrderBy

I am litle curious about what sorting algorithm is using OrderBy (linq to objects). quicksort? heapsort? introspective sort ? As i see in MSDN documentation List.Sort is using introspective sort: ...
-1
votes
3answers
620 views

Is it possible to implement an infinite IEnumerable without using yield with only C# code?

Motivation The main idea is to explore and understand the limits of how far one can go with the basic LINQ primitives (Select, SelectMany, Concat, etc.). These primitives can all be considered ...
12
votes
4answers
975 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>(); ...
3
votes
2answers
303 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 ...
2
votes
4answers
228 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 ...
2
votes
2answers
331 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
1k 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. ...
43
votes
5answers
17k 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
282 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
281 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
614 views

Best way to remove list items from an existing record

Ok more of a conceptual question here: Say I have an existing record of type Meeting. When I go to edit the meeting I have a listbox with all current meeting participants, and one with all employees. ...
-2
votes
2answers
681 views

How do I tell the cases when it's worth to use LINQ?

Many things in LINQ can be accomplished without the library. But for some scenarios, LINQ is most appropriate. Examples are: SELECT - ...
0
votes
2answers
1k views

LINQ TO SQL or ADO.NET? [closed]

What is the best choice LINQ TO SQL (.DBML) or using ADO.NET with procedures for a database with 29 tables and about 30 concurrent users that will run the system that I am going to build? I know that ...
4
votes
3answers
2k views

Is querying KeyValue Pairs efficient compared to two-property objects?

I'm working on a webservice and I'm returning JSON. However, I'm returning a List<KeyValuePair<string, int>>, since that's all I'm really ever going to be dealing with (property => value) ...
4
votes
2answers
1k views

MVVM Reporting App Approach ? Data Access Layer?

I'm trying to follow the MVVM pattern in a reporting / statistics application that I'm making in C# / WPF. I have made many model classes to hold properties as a starting point. Some of these models ...
1
vote
2answers
996 views

Best practice modelling an active record entity using Linq-To-SQL as DAL

Currently I'm starting a new system on my company, and we are using a good separation between models, views and controllers, basically using Asp.Net MVC 3 for the user UI, and a C# class library for ...
4
votes
3answers
897 views

LINQ to SQL - Business logic in another assembly?

So I am trying my hand at this whole tiered application thing with ASP.NET 4. The software I've developed is a maintenance nightmare and it isn't very well organized. I've done some looking around ...
9
votes
6answers
830 views

As a new programmer, how much time should I spend learning new libraries?

As a junior programmer, how much time should I spend focusing on new libraries or language features, as opposed to learning how things worked before those libraries came about? How dangerous is it to ...
6
votes
4answers
1k views

Best algorithm/practice when creating a search mechanism for your database? [closed]

I have been designing a database where it is very important to provide users with a good search mechanism. So I was wondering what some of the best practices are for using keywords to search over ...
0
votes
3answers
500 views

Are there any good resources for refactoring existing C# code to use LINQ while keeping your tests passing?

I've been teaching myself a little LINQ and an exercise I thought would be useful was to take my existing Project Euler C# code, which I built using Test Driven Development and gradually convert it to ...
10
votes
9answers
2k views

LINQ Style preference [closed]

I have come to use LINQ in my every day programming a lot. In fact, I rarely, if ever, use an explicit loop. I have, however, found that I don't use the SQL like syntax anymore. I just use the ...
1
vote
2answers
260 views

C# Linq to <blank> which type is most used and which are most hated/unneeded

I have read and used many good Linq to . I have also read that some of the Linq to __ are not worth learning as there are better techniques. I was just wondering which of the bunch should I ...
15
votes
8answers
12k views

Senior Interview LINQ questions [closed]

I'm preparing a LINQ section in interview questions for senior programmers. What are the most interesting questions in LINQ to include? And why?
2
votes
4answers
2k views

Should I be learning Linq, Direct SQL Commands (in .net), EF or other? [closed]

Basically, I have a very good knowledge of plain old SQL coming from Classic ASP programming. Over the past couple of months, I have been learning C# and today was my first full day at MVC 3 (Razor) ...