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

learn more… | top users | synonyms

3
votes
3answers
68 views

LINQ foreach - error handling and general improvement

I'm looking for two kinds of feedback: Is there a better way of doing what I'm attempting to do? Any obvious weaknesses that could potentially cause problems? The code in question (I've broken it ...
0
votes
0answers
19 views

Using linq for asssign values from one list to another [on hold]

I have two list namely RptDataLst and SelectedStudsKgto5. Both lists are of different types but have some common properties. What I want to do is assign all values fro SelectedStudsKgto5 to RptDatlst. ...
10
votes
3answers
66 views

Read/write to XML using LINQ

This will compile, but I'm thinking that this implementation of read/write is very hard coded and would not be easily adapted to larger situations where large XML documents are being processed or if ...
2
votes
2answers
64 views

Divide certain distinct row values into separate columns

This might be difficult for me to describe clearly but I will try anyway. Also note that this is entirely speculative; it might not even be able to run any faster (that is why I am asking). This is ...
0
votes
0answers
33 views

What is a more efficient way of coding this linq query? [closed]

What I'm trying to do is check if I have a row in the database with a matching date and if I do then update the value and if I don't then insert a new row for that date. I'm getting a null object ...
5
votes
3answers
106 views

Code redundancy issue while feeding dropdownlists

I have a dashboard to manage a learning center system. There are scenarios like admin create learning center and define a classroom in it and then assign some courses in it and assign students to ...
13
votes
9answers
614 views

How can I refactor to avoid repetition finding the index of strings in a list?

I have a list of strings where I want to find the index of a first- and second-choice video compressor. Logic: If the first choice is available, return its index. If not, and the second choice is ...
1
vote
1answer
61 views

Simplification LINQ query and other code

I need to simplify the below code as well LINQ query: ...
1
vote
2answers
65 views

Split a list into equal parts that using LINQ in a way that has good performance

So I have a method that looks like this: ...
5
votes
2answers
143 views

Best way to get the list of XML files

I'm a newbie in the use of LinqToXml and I wonder if I can improve this snippet. ...
3
votes
3answers
154 views

WorkGroup Data Service with JSON / Web based API

I'm wondering if this code can be made more clear and fluent: ...
3
votes
2answers
139 views

Sorting by patients' name or birth

Is there a way to write this simpler? ...
-1
votes
2answers
68 views

Sorting array with respect to two properties

I'm sorting with respect to Width and Length. However, Width has the significance ...
5
votes
1answer
530 views

Sudoku Solver - Recursive Solve

Any ideas on making my code a bit more clean and efficient? Any criticism is appreciated. I don't like that I'm calling my lengthy DeepCopy method so many times, ...
3
votes
1answer
44 views

Parent with N-Childs where each child can have N-Childs

I know my question sounds strange but I have a situation in which I have Parent Data which can have 'N' Childs and each child can further have N-Childs and so on. So its Like. Parent a. Child ...
2
votes
2answers
77 views

Linq C# pulling from table row into input fields

Today is the first time I've used Linq, so I wanted to get a code review on this and make sure I'm going about it correctly. I'm filling text boxes and dropdown lists from a table row. ...
0
votes
1answer
88 views

Approximate integral in one line of code

This is what I came up with: Version 1: ...
1
vote
1answer
79 views

LINQ method to create objects of different types

I have the following code inside a method: ...
5
votes
3answers
87 views

Summing some datum for requests in each domain that fall in a date range

I have a LINQ query which works fine. I am however very interested to understand if this can be written in a more optimum way... ...
20
votes
2answers
240 views
+50

Wait, is this… LINQ?

Context I'm working on a little project that consists in a series of Microsoft Excel add-ins (.xlam). The code being submitted for review here, is located in the ...
2
votes
2answers
122 views

Improving the performance of Linq based solution

Again, out of fun on saturday night, I decided to solve the following problem from CodeEval. The challenge is finding the index of the lowest unique number. ...
3
votes
1answer
85 views

Insert missing records in a list with LINQ

We have a table with periods, and other child tables with these periods and values for combinations of product + location. Based on selected periods, I would like to add any missing rows in the child ...
3
votes
1answer
115 views

Efficiency of nested LINQ foreach loops

I've been working on an older project with framework is 3.5 as the target. There is a new user control that displays a list of data from a web service. I hit the web service (Soap/XML) and deserialize ...
8
votes
3answers
308 views

Indentation on a long (ish) linq chain

I have some code that loops through directories named for years (e.g. /2011/, /2012/ etc) which each contain files whose names ...
5
votes
2answers
102 views

Longer LINQ Chaining

Anyone have ideas on how to improve this code at all? ...
0
votes
0answers
37 views

Looking for a more efficient way to perform this query [closed]

The following query works, but there must be a more efficient way to get the data needed. I'm looking for the sales from a complete client listing for a specific user for last year and this year. ...
-2
votes
2answers
143 views

Optimizing nested loop for an array within a list [closed]

How can I optimize the following code, with LINQ or some other trick? Bird is a class which has different properties id, name, etc and Nest which is an array of places. ...
4
votes
1answer
97 views

Returning a list of income for a month

My current code takes 2.7-4.5 seconds to complete, is there any way to make it faster? I need to return a list of the income in all days in a month. My idea was to loop through the days of one ...
2
votes
1answer
281 views
2
votes
1answer
481 views

LINQ query using StartsWith and Contains to limit the results for an autocomplete field

As a source for a jquery-ui autocomplete field, I've written this action: ...
3
votes
1answer
90 views

Find the number of Colleges offering Combinations of Levels: Performance

I have been using entity framework 5 as DataAccess layer for my application. I have a case where there are a set of Levels offered. And I have a set of ...
11
votes
2answers
774 views

CSV reader using StreamReader and LINQ

Mostly due to readability, I am using the following code to find a specific csv file on a drive read that CSV file using a streamReader parse it into a ...
-1
votes
0answers
48 views

Optimizing searching and comparisons [closed]

There are big words, small words and "rarity" of the small wards. I have to find for each small word that big words, which starts with this small word. And take 10 of them with top rarity. I ...
5
votes
1answer
102 views

Producing the intersection of several sequences

Based on this SO answer I have created a method that produce the set intersection of several sequences: ...
3
votes
1answer
281 views

Compare / Join two object collections LINQ

I have two csv files that I need to compare and merge together. There is a 'big' list with many records and columns of data and a 'small' list of the desired records and some additional data. The ...
4
votes
1answer
83 views

Is this the optimal way to write “find these IDs in a list of objects” using linq?

I've got a situation where I have a list of Organizations (code to follow), and a user has a list of OrganizationIds (ints). I ...
0
votes
3answers
144 views

Linq query performs poor according to performance analyzer in VS2012

I've a Linq query that performs poorly: ...
5
votes
1answer
88 views

Optimize code block for LINQ and non LINQ

I have 2 code block to do same a work and have same target create some thing, but I don't know which block is the best (I mean LINQ or non-LINQ)? First of all, can anyone tell me how to optimize on ...
7
votes
2answers
165 views

Convert a list of sets into the minimum list of non-intersecting sets

I have a list of sets. The same items may appear in multiple sets. I want to transform this into a new list of sets where: Each item only appears once in the entire list of sets. For each set in ...
1
vote
1answer
81 views

Improving iterative manipulation on XML elements

In this reply, there's an example of how to remove a node from a XML structure. ...
1
vote
1answer
381 views

Dynamic Linq from string with EF

I wrote an EF browser to dynamically navigate through entities. Beside basic properties of system types, each entity can have several singular or plural navigation properties. In order to support all ...
2
votes
1answer
162 views

Tasks and WaitAll\WhenAll

Could you help me to speed up/optimize this code: ...
1
vote
4answers
95 views

Checking if there are tags or categories in the database

The code below is used to check if there are tags or categories in the database. If they exist, they are not added to the database, otherwise they are added. Is this code efficient and easy to read? ...
13
votes
3answers
859 views

Using C# properties for simple operations, where should I draw the line?

Should I be putting Linq statements inside of an objects properties? Is that a best practice or is that a no no? Also if that is ok, where do I draw the line with this? I assume db access is ...
2
votes
1answer
54 views

Is there a better way to handle multiple join statements in a linq query? [closed]

I am rewriting a VB.NET app into C#. I won't subject you to the original code. I am mainly looking for a better way to handle all the join statements that are being done. I am dealing with a legacy ...
10
votes
1answer
104 views

Refactor VB.NET to C#.Net using Linq

I am rewriting a VB.NET application in C#. I will not subject you to the original code because it's pretty messy. Below is the converted C# code: ...
4
votes
4answers
343 views

A better way to do LINQ projections

I was wondering if there's a better way of doing LINQ projections than what I'm doing below. This method is one of many methods creating a view of an object tree. The first thing that I don't like is ...
3
votes
1answer
47 views

Updating properties and states

I am rewriting a VB.NET application in C#. This code was originally done in 50 lines and I am trying to clean it up. As you can see I have gotten it down to 10 but I still feel its ugly. I want to ...
3
votes
1answer
78 views

Changing these two functions into one function

I have two functions that are similar. The only differences is that they're using two different models. How can I change them into one function? ...
5
votes
1answer
85 views

ListBox Update Handling

I have UserGroups for Users to be assigned to in a ListBox in HTML form. Items from listbox can be multi-selected or completely ...