try
{
}
catch (DbEntityValidationException dbex)
{
string errMsg = string.Empty;
foreach (var eve in dbex.EntityValidationErrors)
{
errMsg += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
eve.Entry.Entity.GetType().Name, eve.Entry.State);
foreach (var ve in eve.ValidationErrors)
{
errMsg += string.Format("- Property: \"{0}\", Error: \"{1}\"",
ve.PropertyName, ve.ErrorMessage);
}
}
return new OperationResult(OperationResultType.Error, errMsg);
}
catch (Exception ex)
{
return new OperationResult(OperationResultType.Error, ex.ToString());
}