86,794 questions
1
vote
0
answers
72
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
146
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
75
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
126
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
119
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
132
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
89
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
130
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
119
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
139
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
158
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
270
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
68
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....
0
votes
3
answers
174
views
How to use custom functions on LINQ statement?
I have an extension that returns true or false if value is null (null == false), called HasValueLite().
When I use the method in a LINQ statement, I get:
System.AggregateException: 'One or more errors ...