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
2answers
105 views

Getting list of daily team goals

The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have ...
5
votes
3answers
77 views

Calculating total sales from each member

I am building a new system that is using some tables from an old system. For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 ...
10
votes
6answers
580 views

Increment up the build number in AssemblyInfo.cs on every build

I just wrote this short little program to increment up the build number for my projects every time I build them. After compiling this exe, I just call it in the pre-build command line. I did take ...
4
votes
1answer
58 views

Am I even using the Entity Frameowrk and/or LINQ the way it is supposed to be used?

I feel like just because the below works doesn't mean it is correct, I want to improve it but I can't really figure out how. Besides the fact it is down right ugly I feel the performance could be ...
0
votes
0answers
20 views

Add chat to an MVC database: Can I condense this code and is it appropriately placed?

I have these relevant tables in an MVC website: Server ServerPlayer ServerPlayerChat Servers have serverPlayers, ServerPlayers have ServerPlayerChats. Simple enough and expectable. I'm using ...
0
votes
0answers
17 views

Linq multiple Filtering [closed]

Well, Hi guys. I have 3 Multiple drowpdownlist which means I can select multiple parameter each column in table such as car.Budget >= 20000 && car.Budget <= 34999 and also car.Budget >= ...
9
votes
4answers
336 views

Generate sequence in Linq

I want to generate a sequence using Linq that goes from 10 to 100 with a step size of 10. The sequence also must contain a custom value (in the correct order). This is what I have now, and I'm ...
4
votes
2answers
82 views

Retrieve Tasks by Employee

I think I've done a decent job keeping this query simple and understandable, but I'd like to know if you have some more advice. My relevant entities are defined like this: ...
1
vote
2answers
83 views

Converting Anonymous To Dynamic [closed]

I have a extension method like following that takes Anonymous type objects and returns it after converting into ExpandoObject which falls under ...
6
votes
2answers
146 views

Inversion of an array that contains indices

I have an array of length n that contains numbers from 0 to n-1 in random order. I now want to "inverse" this array to one that where index i corresponds to the location of i in the source array. ...
3
votes
1answer
45 views

Linq sorting on sort order of inner group

Is this the best way to do this sort? ...
5
votes
2answers
92 views

Better method for updating data table

I have completed an application which gathers specific records and marks them as Collected. As of now, the application runs perfectly, does exactly what I need it ...
5
votes
1answer
58 views

Identical linq for different index

I am parsing excel data and need to create object based on StartDate-EndDate difference. Is there a better way to have only one linq perform this task and return two different result sets ? Only ...
6
votes
2answers
188 views

How to determine expiration date based on list of months in which to refresh?

Original question and code block moved to the end because it seems that using a List<int> made the algorithm much easier than my real situation I have a list ...
-2
votes
2answers
107 views

Is this correct way to use loops or should it be in LINQ?

The results variable is coming from an API that have a arrays in arrays, etc. I have made a foreach with ...
10
votes
5answers
293 views

Finding elements inside ExpandoObject

Is it possible to simplify the code below? ...
3
votes
2answers
113 views

How to get the Split value from collection?

I have the following key value pair in an array, and am trying to extract and load them into a collection. The below code is working but it can be optimized using Linq: ...
9
votes
3answers
284 views

Refactor foreach statement to LINQ

I have been working on a project and I'm actually refactoring some code. I have encountered myself with lots of foreach and if statements, which could be easily replace with LINQ. But I have this ...
3
votes
1answer
39 views

Refactor C# OR statement using Linq

How can I write this OR statement better, allowing for growth in number of values? var isNewFile = (progressID == 10 || progressID == 20 || progressID == 21); I ...
6
votes
1answer
189 views

Reduce or improve Linq query with nested from-where clauses

I am new to linq to objects in C#. I have the following query which works adequately. Is there someway to reduce or rewrite this query using joins or something else? ...
5
votes
2answers
209 views

Optimising and error handling Linq query

I have 2 tables as below: Downtime DowntimeCode I am then doing this to get the Description field from the DowntimeCode table for the DowntimeCode with the sum highest value in the Downtime ...
1
vote
1answer
145 views

Making adding to a dictionary more efficient?

I have the following code and it's taking quite some time to run. I'm getting an Out of Memory Exception due to the high volume of answers there are. Is there any ...
13
votes
3answers
443 views

Multiple indexes over an in memory collection for faster search

I have a big in-memory collection of following simplified class: ...
1
vote
1answer
139 views

A genric extension method to filter Linq-EF queries

I have various types of EF entities, all of them have a navigation property called "Employee". When generating reports the user will have the option to filter the report according to the different ...
8
votes
2answers
181 views

Should a year and month be stored as separate fields or as a date?

We have a table with calculated data that groups sales by product, year and month, to provide fast querying for statistics. My colleague argues that the year and month should be two separate fields, ...
4
votes
1answer
104 views

Convert looping statement to linq mode

I have a model object class like this ...
0
votes
0answers
90 views

Can this DbGeography calculation be done better?

Given the following piece of code, can it be done better: ...
6
votes
2answers
196 views

Improving speed of moving average calculation

I am hoping to make this method run a little faster. I typically need to run this on a list with more than 100000 entries. Note that at the start and end of the list, I wish to weight the average so ...
2
votes
2answers
121 views

Order by performance

This is code is taking 10 seconds for just 64 items. I'm just wondering if there is a faster way instead of using OrderBy in Linq (I'm thinking about using Sort). ...
7
votes
1answer
320 views

NHibernate select with Query Over optimization for user roles base case

I have a complicated select procedure that I solved with a 5 query transaction, so I am posting it here to get suggestions on how I can shorten it up a bit. I am hoping that someone can help me make ...
5
votes
1answer
136 views

Refactoring chart generator in Linq

I'm kinda curious how I'd refactor this in the best way. I've only used Linq for simple queries. What it does: Depending on the type that is submitted, we're grouping events or payments by ...
16
votes
4answers
320 views

SudokuSharp Solver with advanced features

Even though it's the first time I'm writing something this "big", it feels like I know C# quite good. It's been nice to learn LINQ also and I am very impressed by the features, and perhaps I have ...
8
votes
1answer
146 views

Poker Hand Evaluator, take 2

This is following up on my previous attempt, which was admittedly done fast and not-so-well. This code attempts to allow comparing two poker hands to determine a winner, not only evaluating a given ...
2
votes
3answers
667 views

Convert Sql LIKE to Regex

I have a bit of code that converts a Sql Like expression to a regex expression for the purposes of a Linq to objects Like extension method. For some time I have ...
3
votes
2answers
146 views

Poker Hand Evaluator Challenge

This week's review challenge is a poker hand evaluator. I started by enumerating the possible hands: ...
5
votes
3answers
179 views

Proper and elegant way of Building a XML Document

I need to build the following XML document ...
5
votes
1answer
229 views

Is there a better, faster, more elegant way to create this dictionary?

I have a List of objects List<myObject> objectList and each object contains a List of strings like so: ...
10
votes
1answer
168 views

C++ linq-like library

I want to implement something like C# Linq in C++ Currently only select and where is implemented, but others should be fairly ...
2
votes
1answer
330 views

Nested select Linq

Is there a simpler and optimized way to calculate listAdminCorePriveleges and privileges ? ...
3
votes
1answer
156 views

Improve speed of LINQ query

How can I improve the speed of this LINQ query? ...
2
votes
1answer
133 views

Is there a way to eliminate the repetition in this linq query?

This is a query to return search results, but I feel it could be cleaned up a little. I just don't know how. ...
5
votes
4answers
393 views

How to optimize a multiple if-else with LINQ?

I have a static class: ...
2
votes
1answer
367 views

Improving MVC 4 DropDownList

I'm currently populating my drop downlists like this... ...
2
votes
2answers
148 views

Add item to an Array 2D using LINQ

I've wrote a generic function to add an item to an Array 2D This is what I have: ...
6
votes
2answers
132 views

Function for obtaining the 3 latest patient vital signs

I'm just putting together a small project, checking to see if this would be the fastest/cleanest way to write out a function that grabs the 3 latest vital signs. Edit: I am thinking ...
1
vote
0answers
3k views

Using LINQ ForEach instead of for/foreach (from a code quality PoV, not performance) [closed]

I was peer-reviewing some code recently and there was a particular thing that bothered me (although I could not tell why), regarding the use of LINQ expressions. Every single loop was written as a ...
2
votes
1answer
149 views

Check if Item exists in Grid using Linq

I have a grid which allows a user to enter a new Grid item. If the grid item exists or the tb is empty it displays the error. Here's the code I came up with. Can ...
1
vote
1answer
76 views

Refactor similar queries but reverse side of inequality operator

How can I refactor this? ...
3
votes
2answers
192 views

Code duplication where impliment extension method for IEnumerable and IQueryable on entity set

Since Entity Set does not support asqueryable, I have to do this. How can I reduce the amount of redundant code between the two methods? ...
3
votes
1answer
268 views

Filtering a collection by an async result

I'm trying to do something like this: var loudDogs = dogs.Where(async d => await d.IsYappyAsync); The "IsYappyAsync" property would return a ...