Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ValidationErrors is not reset?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01622996
Message ID:
01622998
Vues:
56
Right. Sorry.

Maybe if I show you the result ?

8/6/2015 4:37:41 PM : **** Currently processing : A$$00100 ****
8/6/2015 4:37:41 PM : DbEntityValidationException.
Errors : 1
The CalculationStatus field is required.

8/6/2015 4:37:41 PM : **** Currently processing : A$$00124 ****
8/6/2015 4:37:41 PM : DbEntityValidationException.
Errors : 2
The CalculationStatus field is required.
The CalculationStatus field is required.

8/6/2015 4:37:41 PM : **** Currently processing : A$$00125 ****
8/6/2015 4:37:41 PM : DbEntityValidationException.
Errors : 3
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.

8/6/2015 4:37:41 PM : **** Currently processing : A$$00215 ****
8/6/2015 4:37:41 PM : DbEntityValidationException.
Errors : 4
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.

8/6/2015 4:37:41 PM : **** Currently processing : A$$00344 ****
8/6/2015 4:37:41 PM : DbEntityValidationException.
Errors : 5
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.
The CalculationStatus field is required.


>>Consider this method:
>>
>>It seems that e.ValidationErrors does not get reset. After multiple catches the previous ierrors remain in the collection.
>>
>>
>>
>>        public static void savechanges(d060Entities context,out bool success,out string message)
>>        {
>>            var s = new StringBuilder();
>>            s.Clear();
>>            success = true;
>>            message = "";
>>            try
>>            {
>>                context.SaveChanges();
>>            }
>>            catch (DbEntityValidationException ex)
>>            {
>>                s.AppendLine("DbEntityValidationException.");
>>                s.AppendFormat("Errors : {0}", ex.EntityValidationErrors.Count());
>>                s.AppendLine();
>>                foreach (var e in ex.EntityValidationErrors)
>>                {
>>                    foreach (var e1 in e.ValidationErrors)
>>                    {
>>                        s.AppendFormat(e1.ErrorMessage);
>>                        s.AppendLine();
>>                    }
>>                }
>>                success = false;
>>                }
>>            catch (Exception ex)
>>            {
>>                s.AppendFormat("error : {0}", ex.ToString());
>>                success = false;
>>            }
>>            message = s.ToString();
>>        }
>>
>
>Your question is unclear. The code seems to be OK, I see no problem.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform