Answer the question
In order to leave comments, you need to log in
How to update a record in a database using EF from a setter?
Hello. Can you please tell me how to correctly update a record in the database from Grid? I'm trying to do this from a property setter, but I keep getting into an infinite loop:
private string _comments;
public string Comments
{
get { return _comments; }
set
{
if (_comments != value)
{
this._comments = value;
using (var db = new DataContext())
{
//var chbk = new ChargebackAnalyzeModel() {ID = this.ID, Comments = value};
db.Chargebacks.Attach(this);
db.Entry(this).Property(x => x.Comments).IsModified = true;
db.SaveChangesAsync();
}
OnPropertyChanged();
}
}
}
Answer the question
In order to leave comments, you need to log in
I think the problem is here:
db.Chargebacks.Attach(this);
db.Entry(this).Property(x => x.Comments).IsModified = true;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question