I am working on mvc project, with repository pattern and entity framework, now on my form i have a sample model
SampleModel
1) name
2) age
3) address
This is an old thread, but if anyone is interested, to extend on Ladislav's solutions, we've come up with a helpful extension method for EF 4.1 and newer:
public static void SetModified(
this DbEntityEntry entry,
IEnumerable>> expressions) where TEntity : class, IEntity
{
foreach (var expression in expressions)
entry.Property(expression).IsModified = true;
}
Obviously you'll need to take away the IEntity constraint unless you're using an interface by the same name for your POCOs.
Example usage would be:
var user = new User
{
Id = Request.Id,
UserName = Request.UserName,
FirstName = Request.FirstName
};
var expressions = new List>>
{
x => x.UserName,
x => x.FirstName
};
context.Entry(user).SetModified(expressions);