Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.

learn more… | top users | synonyms

2
votes
3answers
75 views

Using Linq to select the first and last values

I want to get just the first and last values in a date range. I have the following code: using (var myEntities = new dataEntities()) { var myValues = (from values in myEntities.PointValues ...
2
votes
1answer
24 views

XML to Windows.Forms.Keys List

It took me a lot of poking around and unit testing to get the code to look like it is right now. So I have a XML file which in part looks like this <FunctionKeys> ...
5
votes
3answers
113 views

LINQ Group query - simplifying

Is there a way of writing this correctly working query more efficiently? I'm asking only to learn LINQ better: var cpuInfo = edgeLPs .GroupBy(k => k.CPU.ID, e => e.CPU) ...
2
votes
1answer
116 views

Is there a more elegant way to rewrite this piece of code?

This is what happens, i have a dropdownbox "ActiviteitAardItems" where ActiviteitAard items can be checked (checkbox). If one (or more) are checked the property Opacity will be changed, and the code ...
3
votes
1answer
82 views

LINQ statement to aggregate data

Teachers can raise 'dramas' which are when students forget equipment, don't do homework or are flagged for concern. Each drama for each student is stored as a separate record. I seek a list of all ...
1
vote
1answer
73 views

MVC4 Linq to Sql Model Structure

Goal: To pass a list of related objects into a view which can then be iterated over using razor syntax. I'm new to LINQ and MVC4. I'm trying to use the repository pattern to manage my model creation. ...
6
votes
2answers
125 views

Left hand search in string

the requirement for our search query is to look for all search words in the beginning of vehicle manufacturer, model and variant name. Case insensitive. The word being a string of characters separated ...
0
votes
1answer
74 views

making this linq query faster

I need the most efficient way to get the value of the searchName, or if null return searchName. I am returning just a single string, so maybe I should search itemRepository.Item instead of Items ...
3
votes
2answers
94 views

Refactoring from .. in .. select to more compact one

Is it possible to write the two following lines of code in a more compact one? IEnumerable<int> collection = from partnerNumbers in contract.Contact.PartnerNumbers select partnerNumbers.Pnr; ...
3
votes
3answers
246 views

Rewrite from .. where .. select to more compact one

This is the code: public DateTime GibSomeStartDate(IEnumerable<int> partnerNumbers, DateTime startTime) { return (from contract in this.databaseContext.Contract where ...
3
votes
4answers
117 views

Finding unconnected sets

I have a list of boxes, and wish to group them into unconnected sets of overlapping boxes. (Note that two boxes A and B may not overlap each other, but if they are both overlapped by a box C, they ...
0
votes
3answers
101 views

New to LINQ, not sure this is best practice

So i have a super class that has a 3 child classes. Those 3 child classes have multiple classes of their own. I was having troubles saving this into XML, so I decided to parse it out and do a little ...
1
vote
1answer
32 views

Linq to sql performance

I'm creating a system and I'm using EF with Linq. Model First. So I create my Model (.edmx) and using it, I generated my database and my classes. like the Usuario (user in portugues. going to keep ...
2
votes
2answers
166 views

To LINQ or not to LINQ

As a fairly new C# programmer I am a unsure about when and how to best make use of LINQ (and also when to choose the expression method syntax vs. the query syntax). This question often comes up for me ...
2
votes
2answers
73 views

Optimizing a distinction code

List<int> types = new List<int>(); foreach (var d in myTableList) { if (!types.Contains((int)d.item_type)) types.Add((int)d.item_type); } I have a table in db called myTable. ...

1 2 3 4 5 9
15 30 50 per page