.NET 6 LINQ: Calculate Time Difference Between Two Dates in Minutes
In .NET 6 LINQ, you can use the 'Select' method to project the desired columns and calculate the difference in minutes between 'ChargingBeginTime' and 'ChargingEndTime'. Here's an example:
var result = Charging_Order.Select(order => new
{
order.ChargingEndTime,
order.ChargingBeginTime,
DifferenceInMinutes = (order.ChargingEndTime - order.ChargingBeginTime).TotalMinutes
});
This will return an 'IEnumerable' of anonymous objects with 'ChargingEndTime', 'ChargingBeginTime', and 'DifferenceInMinutes' properties.
原文地址: https://www.cveoy.top/t/topic/l1Lh 著作权归作者所有。请勿转载和采集!