Posts

Showing posts with the label Lamda expression

How to use lamda expression for updating using LINQ

This is small example showing how we use lamda expression in the programming section , Generally we use lamda expression when working wiht LINQ , or the classs of list type where need to get the data based on any where clause. public Boolean Update(string id) { int flag = 0; string str = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; foreach (var c in obj.Task_Details.Where(x => x.task_no == id)) { c.task_date = str; flag = 1; c.status = "Complete"; } obj.SaveChanges(); if (flag == 1) { return true; } else { return false; } }