Пример #1
0
        /// <summary>
        /// This method shows an easy method to get violations on
        /// required properties not set and length of field violations
        /// </summary>
        /// <param name="pMemberList1"></param>
    public void AddBadMember1(ClubMember pMemberList1)
    {
        using (var context = new ClubMembersEntity())
        {
            context.Entry(pMemberList1).State = EntityState.Added;
            try
            {

                context.SaveChanges();

            }
            catch (FormattedDbEntityValidationException fve)
            {

                mHasException = true;
                _validationErrors = fve.ValidationErrors();
                _validationErrorMessage = fve.Message;

            }
            catch (Exception ex)
            {

                mHasException = true;
                mLastException = ex;

            }
        }
    }