86,793 questions
-4
votes
2
answers
160
views
A list object gets the last five years of an object [closed]
Is there a way I can get the last five years of an object?
I been trying to use Max to get the maximum year and then use range to get all the objects within that range:
using System;
using System.Linq;...
1
vote
0
answers
78
views
How would I use N.EntityFramework.Extensions to insert into another table
I am trying to use the InsertFromQuery() to add data to a SQL table:
await cx.Users
.Where(x => x.Country == "Romania")
.InsertFromQueryAsync("Mailbox", mb => ...
-6
votes
1
answer
148
views
Can someone please assist with a C# LINQ question? Sorting is not working [closed]
I'm trying to get a multi line graph with Google charts. I am having an issue with sorting the data properly.
My data is as follows:
public class TemperatureReading (extra only, more fields present)
{
...
1
vote
1
answer
77
views
EF Core populating its navigation although it shouldn't
I am reading the book C#12 In a Nutshell. The author says:
Loading navigation properties
When EF Core populates an entity, it
does not (by default) populate its navigation properties:
using var ...
1
vote
0
answers
127
views
Guid list with contains in Where returns 0 results [closed]
In my ASP.NET Core project, I have a Discount table that stores related product IDs as |-separated Guid strings. I split these IDs and try to fetch the related products from the Product table.
Here's ...
3
votes
1
answer
120
views
Get top 10 with the highest sum of column A, While the sum of column B does not exceed 625
We have a data table that have some data in column A, column B, column C (id).
Note that the list is near 250 items. Here's it's a small representation
In c# it gives a list like this:
List<Item>...
2
votes
1
answer
137
views
Deserialize complex JSON with data in keys
I am building an editor script for Unity to import a complicated blueprint JSON asset extracted from another game engine. Some of this data is stored in the keys, meaning I cannot follow a typical ...
1
vote
1
answer
92
views
Why does await Task.WhenAll() with LINQ Select lose exception stack trace?
I’m using Task.WhenAll with LINQ to run multiple async operations. However, when an exception is thrown inside one of the tasks, the stack trace seems incomplete compared to when I await each task ...
-5
votes
2
answers
133
views
Why do I need to assign the result of a order by LINQ query to a variable to get the sorted list? [duplicate]
Decided to take a test in C#, I have a class called Purchase which has three string properties namely CustomerName, Item and Amount. I created my own implementation of the Purchase class whose details ...
0
votes
2
answers
121
views
C# LINQ - Splitting a List into two variables by a condition [duplicate]
Let's say I have someList of things I want to split into two separate lists by some condition.
I've thought of 3 options:
// 1 - two Where's
var trueGroup = someList.Where(x => x.SomeCondition);
...
-2
votes
1
answer
140
views
Retrieve previous record to current list for calculation
Goal:
Get previous record to current list for calculation using LINQ
Result:
Date | EatenFoodInKg | CompareToFoodFromYesterday
2000-01-11 10 9 (10-1)
2000-01-10 ...
3
votes
1
answer
159
views
Why is a simplified version of Max(decimal) slower than Linq's implementation?
I'm working with some benchmarks, and I noticed some odd behaviour with my methods vs. Linq's implementation. Testing on .NET 9, X64 RyuJIT.
I'm determining the max value within a decimal array. In ...
7
votes
2
answers
274
views
How to reliably find out if an IEnumerable<T> is materialized?
I'm used to have a method in my code base, that basically does something like:
return source as IList<T> ?? source.ToArray();
where source is an IEnumerable<T>. I used this method to make ...
2
votes
1
answer
76
views
Gets AggregateException on LINQ extension method using LINQKIT
I'm creating a LINQ extension using LINQKIT, but I can't figure out why I get this error
System.AggregateException: One or more errors occurred (no method 'InGroupsImpl on type 'SLT.Assets.Extensions....
-2
votes
1
answer
69
views
Linq sort entity if JSON value exists [closed]
I have a db table column where some properties are stored as json. Here is an example :
properties
----------
{ "SortBy" : "ASC" }
List<MyItem> items = await this.dbContext....