I have following code for updating user's column
public void UpdateLastModifiedDate(string username)
{
using (AppEntities db = new AppEntities())
{
var result = from u in db.Users where (u.UserName == username) select u;
if (result.Count() != 0)
{
var dbuser = result.First();
dbuser.LastModifiedDate = DateTime.Now;
db.SaveChanges();
}
}
}
I have other's 2 function of almost same of above function for UpdateLastLogOutDate, UpdateLastLoginDate. So, I decided to define single function for all to update Last Date like:
public void UpdateLastDate(string username, string ColumnName);
Here, I can not put ColumnName variable like this:
dbuser.ColumnName = DateTime.Now;
Is there any other way to do this using LINQ