I'am trying to create an update method in a generic repository as a data access layer
i have an entity like this:
[Table]
public class Product
{
[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "Int NOT NULL IDENTITY")]
public int Id { get; private set; }
[Column(UpdateCheck = UpdateCheck.Never)]
public string Name { get; set; }
....
}
i set `Update Check = true` for all the fields exept for the id and i set the `asModified` propery in the attach method to true which i found as following:
public void Update(T entity)
{
_db.GetTable<t>().Attach(entity, true);
_db.SubmitChanges();
}
</t>
but i keep getting the same exception:
An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy.
so what's the problem ???
or Do you recommend any other approches to create an update method in a generic repository except createing a timestamp column as a version number.
Thanks in Advance;