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
0answers
40 views

Subtract from line and move to next

I want to subtract from the line with oldest date and where counter > 0, and when it reaches 0 I want to subtract from the next oldest line with the same itemId and ...
4
votes
1answer
53 views

IQueryable Extensions working on expression for collection property

Followup to Repository searching code duplication My goal currently is to make my current implementation of my repository's IQueryable filtering less duplicative. First, I looked into passing ...
4
votes
2answers
158 views

Migrating data using entity framework, linq and recursion

I have a piece of code to migrate data from an old app to a new app. The data represents the user's websites. In the old app the user only had one section for websites, on which you could add any ...
4
votes
1answer
65 views

Retrieving website categories from a three-level hierarchy

I've been trying to fix this performance bottleneck in my web app for a while now. Here is what the data looks like on my web page: Here is how I get this data in the controller: ...
3
votes
1answer
53 views

Unfold a 2D array spiral in C#

The purpose of this function is to turn a 2D array of sorts into a single-dimensional array by reading it in a spiral fashion. In the array: 1 2 3 4 5 6 7 8 9 ...
2
votes
3answers
138 views

Pangrams implementation using Linq

This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this ...
3
votes
2answers
58 views

Diagonal difference using Linq

Recently, I have been trying my hands on LINQ. So I've implemented the diagonal difference using Linq in Hackerrank. I know a similar question has been asked in python Diagonal Difference Here is ...
3
votes
2answers
109 views

Implementing SOLID Principles - LINQ TO SQL

I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved? I have just started learning about solid ...
0
votes
1answer
65 views

Showing data on days range: 15, 30, etc

I have to show a dashboard based on days range like -30, -15, 0, 15, 30. I have taken this approach: Produces results withing 1.56sec. I want to know a better approach to implement the same thing with ...
3
votes
1answer
133 views

Chunking a list into separate lists of 5, and then iterating through each

I'm writing a service that receives a list of Latitude/Longitude objects, prepares them for transaction, and then calls a web service to write them to the organization's Mainframe. According to the ...
1
vote
0answers
44 views

XML settings file read/write Design Patterns [closed]

I'm new to C# and would like to create a WPF app with xml config file. I have a certain setting file written by using System.Xml.Linq;. And I'd like to write ...
1
vote
2answers
63 views

Filtering data for jQuery DataTables

Using DataTables (Table plug-in for jQuery) with server-side processing, I had to create filtering for my data with good performance. However, in my opinion it's kinda ugly, especially the part of (<...
7
votes
5answers
2k views

Too Many Staff Meetings

I recently got in really deep on a question to find the overlapping meetings and I rewrote a bit of the code and added some things to the code, and I would just like a general review of my code and ...
3
votes
2answers
274 views

Creating monthly files from an annual file

I am interested in learning a more succinct (or better performing) way of writing the following working code. I just figured it out but it is pretty messy. This program takes a file full of daily ...
4
votes
1answer
60 views

Delete records from multiple tables when deleting a subproject [closed]

In my program I am deleting subprojects using LINQ. It's incredibly slow. There is a lot of cascade on delete's here so I am deleting from multiple tables. Any help and tips would be appreciated. ...
3
votes
3answers
143 views

Factoring WHERE clauses in IQueryable

I recovered some spaghetti code and I have to refactor it. I do not want a method with over 200 lines, for me it is not object oriented programming. I am trying to ponder on the question and would ...
1
vote
2answers
108 views

Reading in a file and ranking result to output file

I am reading in a file which consists of scores between two teams. The team that wins gets 2 points, if the teams tie both teams get one point. The result is ranked by points and if there is a tie ...
4
votes
3answers
144 views

Concatenating two IEnumerables with a limit

I've been playing around with generators, generics and extension methods in C# (5.0) and wanted to create an extension method for IEnumerable, which would append ...
2
votes
2answers
150 views

Creating a random code and saving if it does not exist

I have created a script to generate 5 random codes, check if any one of them exists in the database, and if not, insert the record. The script will throw an exception if a single code could not be ...
1
vote
1answer
75 views

Simple generic linq expression generation method

Here is my generic method for creating linq expression based on field name of a type, operator (as enumerations of operators generated from XSD) and value of field ...
0
votes
2answers
58 views

LINQ sorting using custom IComparer is very slow

Joining a project with some crazy LINQ sorting statements and after refactoring by the team using a custom comparer we found out that it is so slow for some data that you actually think it is an ...
4
votes
2answers
98 views

LINQish command line parser

I needed to parse some command line switches from a string and I tried to do it the easy way so I just wrote this: ...
4
votes
2answers
67 views

Search for variants of keywords using LINQ

First, I'm adding words entered into a search field to an array. Then, I'm getting results from a stored procedure on SQL Server using Database First approach with Entity Framework. Finally, for ...
8
votes
1answer
90 views

Linqy Sudoku game generator

I created a class that is able to generate a Sudoku board. The following board generation steps are made: Create a valid board with numbers on all squares, row by row Basically I always generate ...
2
votes
2answers
348 views

Check if an Array of Arrays contains a value in node js

In C#, I could check if any of the nested List collection has a value. Example of such structure Check a List[]> contains a value using Linq ...
6
votes
3answers
274 views

Checking whether relations are equal to foreign fields using LINQ Any()

Can you find a more understandable way to write the following one-liner? ...
3
votes
3answers
73 views

Add multiple instances of a property to a list [closed]

I'm a novice programmer asking first question here although I've gotten tons of help from previous questions. The following code is abstracted from what I currently have working. ...
10
votes
4answers
301 views

Split IEnumerable by predicate

In order to divide an IEnumerable in C# by a predicate, I implemented the following (in a static class): ...
2
votes
1answer
30 views

sort group item by attribute

I have a repository method which retrieve a list of items, for example: ...
6
votes
1answer
99 views

LINQ Provider: Supporting Projections

Up until recently, my LINQ-to-Sage provider didn't support projections, so the client code had to explicitly "transfer" to LINQ-to-Objects, like this: ...
-1
votes
1answer
71 views

create generic method for two different anonymous types

Function 1: ...
3
votes
2answers
128 views

Countable and uncountable sets in .NET (IEnumerable and Predicate)

There is a full featured support of countable sets in .NET: IEnumerable<T>. What about uncountable sets; sets defined by predicate? How can they be ...
4
votes
1answer
74 views

Loading and updating data from system A to system B

I need to transfer purchase order (PO) information from SQL Server into Sage 300 ERP, so using my Linq-to-Sage implementation, I wrote a little console application that connects to a SQL Server ...
0
votes
1answer
53 views

Is my LINQ query safe and efficient?

I am relatively new to LINQ queries as I normally just use plain SQL to get my data back but i am changing for the good - Anyway obviously with SQL you pass in parameters so you do not get any SQL ...
2
votes
3answers
621 views
0
votes
1answer
101 views

Count check before Linq Single() call

Should I check Count before Linq Single() call if I expect only one element? ...
4
votes
4answers
542 views

PermMissingElem- find the missing element in a given permutation in C#

I just encountered this question in codility but apparently this question has been asked in java already (here, here). Task description A zero-indexed array A consisting of \$N\$ different integers ...
5
votes
1answer
67 views

Merging trips to the same location with overlapping dates

I have a SQLite database that only contains the holidays for 1 user. I have a new Trip object (newTrip) that has a ...
4
votes
1answer
121 views

Retrieving collections from a database

I have two collections that I want to retrieve from the database and associate with each other. My solution works, however I know it isn't the most elegant one. Do you have any suggestions on how to ...
6
votes
1answer
992 views

Find the odd occurrences in an array

Recently, I came across this problem on Codility. I am aware there is a bit of similarity to Finding all integers in an array with odd occurrence and Most common occurrence of an int in an array . But ...
1
vote
1answer
77 views

Conditional aggregate whilst constructing array

I have the following snippet of code which gets a load of time intervals (every hour, every 2 hours etc), then groups the results for each of the intervals (e.g, the max value for each hour). This ...
0
votes
1answer
31 views

disable other default row- Entity framework

I have a table that name is Store , In Store Table , just one row can IsDefault=true at ...
0
votes
1answer
177 views

Map a hierarchy of nested DTO objects to a list of business objects [closed]

Consider I download my data into this data structures: ...
4
votes
2answers
97 views

Stitching Linq with if blocks

I recently learned about Linq's deferred execution and a little clearer understanding of IEnumerable. I came back to some code that I had written and decided to change with Linq extension methods. (...
3
votes
1answer
100 views

Rolling up Invoice Items Matching Certain Criteria

I have a listing of invoice line items that I need to apply some convoluted business logic to. We have another listing of items that I compare the invoice items to and if I find matches, I then need ...
1
vote
2answers
62 views

Find items in collection one that are the greatest value less than an item in collection two

This is hard to explain. I wanted to get all of the items in collection one (ints in the example below) that are the highest values that are lower than any of the items in collection two (otherInts). ...
4
votes
2answers
179 views

Customer search using LINQ followed by conditional filtering of results

I have a search function in my class which checks various class property values for null or certain values and queries the database based on those properties. This how my function looks like now: <...
1
vote
1answer
103 views

Getting price for one firm by week

I've a lot of data whit prices of a product from different firms by week. I've a class named WeekPrice witch contains a list of ...
0
votes
1answer
63 views

Skip by Id on large list

This is in ASP.NET MVC, but that shouldn't make a difference. I have a large number of rows in my database for Songs. ...
3
votes
2answers
177 views

Operator-based switch for a database query filter

I am currently working on a method, that can search based on a value and an operator. Currently I check which operator was supplied to the the method in a switch, and do operations accordingly to it. ...