If I have the following object:
public class PocoWithDates {
public string PocoName { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateUpdated { get; set; }
}
matches a SQL Server 2008 (R2) table with the same name / attributes ...
How can I automatically: - Set up the field DateCreatedand DateUpdatedwhen you do INSERT - Now set the field DateUpdatedwhen doing UPDATE
When I speak automatically, I want to say that I want to do this:
poco.Name = "Changing the name";
repository.Save();
Not this:
poco.Name = "Changing the name";
poco.LastModified = DateTime.Now;
repository.Save();
Behind the scenes, "something" should automatically update the DateTime fields. What is this "something"? I am using Entity Framework 6.0. Is there a way that EF can do this automatically? I know that MySQL can do something like this. Or using triggers / stored procedures in SQL Server. But I do NOT want this.
:
Entity Framework/SQL2008 - LastModified ?
/ EF 4.0. EF6.0 DBContext. , EF6.0. , - , SaveChanges() Add() EF4.0 EF6.0.