Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

join 2 list rows into one row and add totals fields C#

var result = list.GroupBy( result => result.TrdID)
                 .Select( gr => {
                 var startDate = DateTime.ParseExact(gr.OrderBy(x => x.Term).First().Term, "yyyyMM", CultureInfo.InvariantCulture);
                 var endDate = DateTime.ParseExact(gr.OrderByDescending(x => x.Term).First().Term, "yyyyMM", CultureInfo.InvariantCulture);                      
                 return  new ProcessedResult
                 {
                     TrdID = gr.Key
                     StartDate = new DateTime(startDate.Year, startDate.Month, 1),
                     EndDate = (new DateTime(endDate.Year, endDate.Month, 1)).AddMonth(1).AddDays(-1),
                     Price = gr.First().Price,
                     Seller = gr.First().Seller,
                     Buyer = gr.First().Buyer,
                     Quantity = gr.Sum(x=>x.Quantity)
                 } 
             });
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# SQLite execute Command 
Csharp :: localhost ssl certificate error in visual studio 2022 .net 6 
Csharp :: csvhelper driver c# nuget 
Csharp :: unity tostring keep decimal part 
Csharp :: bitwise even or odd 
Csharp :: c# fastest way to find item in list 
Csharp :: c# create dll runtime 
Csharp :: cqrs design pattern .net core 
Csharp :: Post and Pre Increment operators in C# 
Csharp :: nullable IList 
Csharp :: c# methods 
Csharp :: player leaning unity 
Csharp :: get patht bim 360 revit api 
Csharp :: create star rating using loop in c# 
Csharp :: pyqt single instance 
Csharp :: C# free text search 
Csharp :: Unity Scale per code ändern 
Csharp :: unity mass unit 
Csharp :: unity gamemanager instance not set to an instance of an object 
Csharp :: vb.net delete a line from text file 
Csharp :: list remove positions c# 
Csharp :: polymorphism in c# 
Csharp :: check list exist in list c# if matches any 
Csharp :: c++ Write a program to reverse an array or string 
Csharp :: c# for loop last iteration 
Csharp :: convert uk string date to DateTime c# 
Csharp :: getawaiter and no extension method 
Html :: You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0). 
Html :: bootstrap text bold 
Html :: http://127.0.0.1:5500/favicon.ico 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =