EntryEntities.Attach
EntryEntities.Attach
Is it possible to Attach objects to contexts?
context.EntryEntities.Attach(entity, true);
??
context.EntryEntities.Attach(entity, true);
??
Here is a simple code example:
Please note that the Customer object has a version field with a trigger on insert and update actions,
setting the version value to current timestamp.
Code: Select all
private void MainMethod () {
Customer c = getFirst();
c.Name = "Test";
DataContext1.DataContext1 context = new DataContext1.DataContext1();
context.Customers.Attach(c, true);
context.SubmitChanges();
}
private Customer getFirst () {
using (DataContext1.DataContext1 context = new DataContext1.DataContext1())
{
Customer c = db.Customers.First();
return c;
}
}
setting the version value to current timestamp.
where can i set this property "IsVersion" ?AndreyR wrote:As I have already mentioned, the entity should have a Version member.
Please set the IsVersion property to true for the property you wish to use as version in Entity Developer.
Please don't forget the database triggers on insert and update actions.