In our controls we have a base class with the following Save function. If the Save entity fails, throws an exception, we call Entity.SetEntityError("Invalid record"). This results in the DevExpressXtraGrid is a error message.
public virtual void SaveChanges( IEntity2 Entity, bool RecurseSave = true)
{
if (Entity != null) {
try {
using (DataAccessAdapter adapter = DataAccessAdapter.CreateInstance()) {
adapter.SaveEntity(Entity, true, RecurseSave);
mDataStatus = DataStatuses.DataSaved;
}
} catch (ORMQueryExecutionException ex) {
mDataStatus = DataStatuses.Errors;
mExceptionMessage = ex.Message;
Entity.SetEntityError("Invalid record");
}
}
}
After the function is called we like to rebuild the grid and like to make the failed row "red", but to do that we need to ask each entity if it is failed or not. The only property I could find is IsDirty, but than the row is getting red at the moment we change the fields.
Is there a way to ask the entity if it failed writing to the database?