You've defined your Product
as an Interface instead of a Class.
Should be:
interface ILastModified {
{
DateTime LastModified { get; set; }
}
public partial class Product : ILastModified
{
/* this prop is declared in the Ef generated class */
//public DateTime LastModified { get; set; }
}
EDIT:
You don't have to use Is
with this change to your method:
public virtual int Update<T>(T TObject) where T : class, ILastModified
{
TObject.LastModified = DateTime.Now
var entry = dbContext.Entry(TObject);
dbContext.Set<T>().Attach(TObject);
entry.State = EntityState.Modified;
return dbContext.SaveChanges();
}
and this way you'll get compile time errors if the type you pass does not implement the interface.