All Questions
Tagged with linq aggregate-functions
46
questions
0
votes
2
answers
45
views
How to use Enumerable.Aggregate without getting CS0411 error
There are two DTO records:
public record struct DateHour(int Hour, double? Value);
private record struct HourSnapshot(uint TotalSeconds, double? Value);
I have another method which works with enum. I ...
0
votes
1
answer
65
views
Using a MAX aggregate in an Entity Framework/LINQ query
I have a project where I need to use Entity Framework Core 7 against a MSSQL database but I'm stuck in bringing the MAX aggregate in SQL as a part of the LINQ statement.
Consider the following data:
...
0
votes
0
answers
109
views
System contains no element on Aggregate call
I have this code that throws "Sequence contains no elements" exception:
autoRefreshWorker = new AutoRefreshWorker(AutoRefreshData, () => {
var items = ((...
1
vote
2
answers
2k
views
EF Linq query with join, group and sum
Trying to construct a LINQ query that performs a simple inner join, groups the data and sums two of the columns. From the examples I've seen it looks fairly straightforward but I must have missed ...
-1
votes
1
answer
74
views
Finding Aggregate Sum of entries in a LINQ expression
I have written a LINQ query that returns a set of objects(anon-type) based on the JOIN condition
var customerOrderResponse = tableOne.Join(
tableTwo,
firstData =...
0
votes
1
answer
47
views
how to return numbers of field depending of another fields on a db table
i stuck trying to get specific data from my database tables.
my table has the follow structure, 3 columns¨: id(irrelevant for this), area, and typeofdevice
im trying to obtain the areas data ordered ...
0
votes
1
answer
88
views
Joining multiple properties of an object using LINQ
I want to create a action link combining two properties of object viz, Name and Id.
This is how I am doing right now,
var hasDetails = collection.Count > 0;
if (hasDetails)
{
<a>(</...
4
votes
2
answers
3k
views
MongoDB GroupBy Aggregate and Count Documents C#
I have a requirement to get the count of documents based on status of customer. So I need to use aggregate function and then group by based on status. I have used following code for that but the ...
1
vote
2
answers
209
views
Difference between usage of an aggregate operator by chaining with Select and not doing that [duplicate]
I wonder if there is a difference between the following statements in respect to both performance and calling-style(e.g. applied the expression to all sequences or objects).
var minPrice = SampleData....
1
vote
2
answers
687
views
C# Anyway to Aggregate from IQueryable (Not AsEnumerable) [duplicate]
Code is the best way to express.
IQueryable<Entity> Sample = dbContext.Entity.Where(condition);
var result = from s in Sample
select new NewList
{
...
1
vote
3
answers
581
views
Aggregate values at hourly interval using LINQ C#
I have the following JSON result from API .
[
{
"ID": "1",
"Value" : "10",
"TimeStamp": "2019-10-21 00:00:00"
},
{
"ID": "1",
"Value": "10",
...
0
votes
1
answer
215
views
Perform aggregate count() on ADO.net Entity data model
I am trying to perform an aggregate count() just like a SQL query would against my database, but instead of SQL I want to use LINQ.
I am trying to use LINQ to query my Entity Framework Data Model ...
0
votes
1
answer
2k
views
Multiple aggregate functions in one query using Linq to SQL [duplicate]
I'm trying to achieve the following in LINQ (EF6):
SELECT count(A), sum(B), average(C)
FROM TableA,
LEFT JOIN TableB ON ...
LEFT JOIN TableC ON ...
WHERE
(very complicated conditions)
The C# ...
1
vote
2
answers
147
views
how to execute a nested group aggregate functions with multi groupBy columns using entity framework and linq?
I have a select statement as following.
SELECT Doc_Id term
FROM [Inverted_Index]
how can I do something like the following statement using entity framework and linq ?
select max(count(term))
from ...
2
votes
2
answers
411
views
How to get average based on list of Ids in entity framework
I have a table let says Products which contains two column(ProductId, Price). I am getting list of product Ids from client(IOS, Android). Instead of iterating over the list and getting the price one ...