Reputation: 17
I want to subtract two numbers from data base table for condition : subtract of all times most less than 8
List<Task> ltask = ProjectDAL.GetAllTasks();
in DB I have Start_Time and End_time
I want to subtract Start_Time from End_time for all end and start value inDB for ex :
Start_Time = 10
End_time = 16
subtract = End_time - Start_Time = 6
var subtract = ltask.Where(x =>x.End_Time - x.Start_Time);
but is not working
Upvotes: 0
Views: 1555
Reputation: 24137
You need to use .Select(...)
:
var subtract = ltask.Select(x => x.End_Time - x.Start_Time);
Assuming that End_Time
and Start_Time
are int
values, this will return an IEnumerable<int>
object. If you enumerate this with e.g. foreach
or .ToList()
, it will calculate the difference for each of the items in the source list ltask
.
Upvotes: 2