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
11 views

C# New XDocument from select statement [on hold]

I am attempting to create a new XDocument from a group statement. Here is what I have: ...
1
vote
1answer
26 views

Eager Loading Deeply into a Model with a Collection Property Whose Type is Inherited

Visual Studio generated this great route for me, where I can load an entity: ...
0
votes
0answers
18 views

Get a list of inherited classes using Linq to Entities

I have inherited classes in Entity Framework. I have a base class (ArticleBase) and two classes Review and Article which inherit from it. I am returning a list of the latest Articles and Reviews ...
2
votes
2answers
48 views

How to find contradiction in order of items in multiple sequences

Suppose you have several sequences: A: 1 2 3 4 5 B: 2 4 5 C: 2 1 3 4 5 D: 3 2 Here, some pairs of list contradicts each other, because they ...
8
votes
1answer
89 views

Linq-to-Sage Implementation

Following-up on my last question where I wrapped the Sage API with a familiar IRepository interface, I decided to push the abstraction a step further, and... ...
1
vote
1answer
35 views

LINQ statements that aggregate sums from a List of objects

I'm packaging data for use in a JavaScript charting library that expects a somewhat odd structure of data in which there is an array of labels and an array of ...
0
votes
0answers
46 views

Optimizing LINQ with SelectMany aggregation

I have the following query which appears to be a bottleneck in my app: ...
2
votes
2answers
73 views

Medical appointment book history

This code correctly returns a View_appointment. Is there a better way to accomplish this with using left joins and unions? I'm trying to learn Linq a little bit ...
0
votes
1answer
50 views

Pull back records that include child records

I am trying to pull back records that include child records for the View I'm putting together. Right now I have a working Linq statement, but it's big, and I think I could make it cleaner. ...
5
votes
1answer
62 views

Categorize episode-file names - Follow up

This is a follow up to this question. I have implemented changes to the code as they were suggested in the previous question and have made a few changes of my own. But it has been mentioned that the ...
2
votes
0answers
50 views

Convex envelope algorithm of random set of points

This is my "naive" implementation of a convex hull algorithm. By naive I mean that I am not using any of the advanced algorithms that exist to solve this problem. ...
11
votes
3answers
790 views

Give me thy name, I'll invoke thee

This generic function invokes a property of a given object by name: ...
5
votes
1answer
55 views

Using LINQ to output SQL data from two tables into XML

I am very new to this. Hope someone could help me suggest how to improve the code. I have two tables where I need to get the SQL data and output it into XML format. I am using LINQ method. Below how ...
6
votes
1answer
133 views

Joining datatables to create a new datatable

I am joining datatables to create a new datatable: ...
5
votes
2answers
97 views

Query Builder pattern with use of FluentApi

Recently, I've come up with an idea of building a custom query builder combine with FluentApi. Expected usage: ...
-4
votes
2answers
93 views

Remove from list value where date less than max date value

How can I improve this code? ...
3
votes
2answers
170 views
0
votes
2answers
34 views

Control DataTable to CSV toString() formatting

Following a question I asked and the advice on SO I implemented the following solution. Are there any downsides to such a solution? Is there a better way to make it changeable when I need to control ...
9
votes
2answers
336 views

Finding the busiest time-frame in a parking lot

The text file containing cars' arrival and departure time will upload stuff from the parking lot. Text will be like this: ...
0
votes
1answer
90 views

Select values from two collections

I have a model: ...
2
votes
1answer
74 views

Simplifying a LINQ expression that finds the largest date smaller than another date

I have a LINQ 2 SQL query that needs to run a subquery in the where clause. The subquery just returns the largest date (from a date column) that is less than or equal to another date (an input to the ...
3
votes
3answers
131 views

Enumerate list with filter criteria

Given the following CreditCard object, how would you get a count of unexpired credit cards? What are the pros/cons of using each method? Or is there a ...
5
votes
3answers
222 views

Sorting a list based on date and time

I have a class that is used to basically store samples from data being read from a system. Within that class is a property that I use to store the date and time of that sample: ...
8
votes
3answers
652 views

LINQ queries improvement - repetition of query

I have a DAL class full of LINQ queries which I would like to improve as I found that I'm repeating myself couple of times. As you can see the part below is repeated couple of times and I was ...
-4
votes
1answer
37 views

Linq to get records of various status [closed]

I converted an Stored Procedure into a Linq Query, but it do not get any records. Stored Procedure: ...
7
votes
3answers
185 views

Fetching a set of event IDs from a database based on a set of company IDs

The following code fetches a set of company IDs from a database if there are any events associated with a company that has a missing property. Because the set of company IDs is embedded into the SQL ...
3
votes
2answers
112 views

Find a serial port device through WMI (windows management instrumentation)

The idea here is to be able to find a USB serial port device connected during runtime, thus not knowing its port number, and use it in the application to retrieve information from the device. ...
3
votes
4answers
167 views

IEnumerable Extensions Linq AllOrDefault() Each()

I recently decided to try and write my own implementation of Linq, which then lead me on to trying to solve some of the problems we have in our code base at work. Our code is littered with the ...
2
votes
2answers
93 views

Linq-to-Sql Contains an int? inside a list of int

Curious if there is a better way to write a repository method that receives argument List<int> and checks if the database ...
2
votes
2answers
109 views

Checking for violation of primary key in a DataTable

I coded this function to check for a violation of a primary key in a DataTable. The main idea is to retrieve a list of every row that the same value of the column ...
2
votes
1answer
76 views

Counting email addresses with different status

I want to count email addresses with different status. I use ASP.NET MVC and this query is supposed to run every 5 minutes on these tables, which every table is on different .ndf files. About 5 ...
4
votes
1answer
131 views

12-week staffing forecast LINQ query

I have a LINQ query that I am having trouble optimizing and takes about 5.5 seconds to run. I am using a view called StaffingResourceData and a table called StaffingForecasts. Each StaffingResource ...
2
votes
2answers
54 views

Grouping over a list of dictionaries

I am consuming data from an API that reads from a SharePoint list. The API is basically this: ...
-1
votes
3answers
63 views

Checking string length limitation and add items to it in a shorter way with Linq

This method has three parameters. If the extension is not null, for each item in list try to add extension to main text in a way that length of result doesn't exceed 20. I wrote this code, but I ...
2
votes
2answers
82 views

Simplify my class mapping common class properties between model and viewmodel classes

I have an ASP.NET MVC 5 app and I map properties between model and viewmodel and vice versa. I could use automapper to do this but since I don't need mapping rules to convince me to use it as I ...
2
votes
1answer
181 views

Linq query performance that use ToList()

This code written by @Rahul Singh in this post: ...
11
votes
2answers
95 views

IdentifierReferenceResolver: resolving at project level

One of the most important parts at the core of rubberduck is the IdentifierReferenceResolver class, which is responsible for resolving each declaration as the parse ...
1
vote
1answer
84 views

Deserializing multiple elements from XElement [closed]

I'm serializing multiple elements using this code: ...
3
votes
1answer
439 views

Using LINQ to perform a LEFT OUTER JOIN in 2 DataTables (Multiples criteria)

I know that exists a lot of solutions about how to create an OUTER JOIN between two DataTables. I created the following code in ...
3
votes
1answer
49 views

Grouping two sets of data

The following method retrieves a list of users and the subscriptions for each user, from my database. That said, it works, but it runs pretty dang slow. I'd like to improve the speed on it. Currently, ...
0
votes
1answer
109 views

Getting prime numbers between a range

I have the following code to get the prime numbers between a range of numbers. Is this the best and fastest method? ...
1
vote
1answer
36 views

Retrieving a list, by iterating through a list

I'm using VB.Net, MVC 5, EF 6, and Linq. I have a list of Integers (category attribute IDs). I need to create a second list of ...
6
votes
1answer
85 views

Sum data that needs to be joined and grouped by

I have a list of patients, Patient class has Prescriptions property, which is a list of ...
7
votes
2answers
81 views

Convert an object to an ordered by SemVer Markdown list

For a small personal project, I am looking to convert an object to an ordered by SemVer Markdown list. You can find the original code for the sort logic here and here for the writing into Markdown ...
-3
votes
1answer
73 views

Which way is better (matching Onion Architecture in MVC pattern) for using Provider?

In onion arch. we have multi layer structre: UI (User interface). BL (Business Logic / Services). RE (Repositories). UI uses BL to get data from RE with some conditions, my question is which is ...
3
votes
1answer
81 views

LINQ filtering query

I often find myself writing LINQ queries like this. I end up testing for Null and zero-counts pretty often, and the code sprawls out to be something like the ...
5
votes
3answers
202 views

Filtering units by a dynamic Lambda expression

I have a simple if statement which, based on user input, determines which expression is going to be utilized. It looks like it can be done better. ...
5
votes
3answers
933 views

Convert Foreach Loop into Linq in C#

I want to convert these loops into simple loop. I want the code to look neat and short. I saw answers related to LINQ but couldn't make out from that. Are there any other possible ways for this ...
1
vote
0answers
101 views

Create JSON object from self-nested LINQ query

I created this function to created nested JSON object using a Linq query. How can I optimize this and make it more readable? ...
10
votes
3answers
120 views

FizzBuzz in accordance with standards

I wrote FizzBuzz. My aim is to use C# Code Standards correctly, and write flexible code. How can I improve my solution according to code standards? How can it be better in general? ...