private void AddTestResultDetailToDB(ODataValidationSuiteEntities ctx, int testResulID, ExtensionRuleResultDetail detail)
        {
            // Write one detail information to the DB.
            ResultDetail resultDetailInDB = new ResultDetail();
            int resultID = testResulID;
            resultDetailInDB.TestResultID = resultID;
            resultDetailInDB.RuleName = detail.RuleName;
            resultDetailInDB.URI = detail.URI;
            resultDetailInDB.HTTPMethod = detail.HTTPMethod;
            resultDetailInDB.RequestHeaders = detail.RequestHeaders;
            resultDetailInDB.RequestData = detail.RequestData;
            if (string.IsNullOrEmpty(detail.ResponseStatusCode))
            {
                resultDetailInDB.ResponseStatusCode = detail.ResponseStatusCode;
            }
            else
            {
                HttpStatusCode? responseStatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), detail.ResponseStatusCode);
                int statusCode = Convert.ToInt32(responseStatusCode);
                resultDetailInDB.ResponseStatusCode = string.Format("{0},{1}", statusCode.ToString(), detail.ResponseStatusCode.ToString());
            }

            resultDetailInDB.ResponseHeaders = detail.ResponseHeaders;
            resultDetailInDB.ResponsePayload = detail.ResponsePayload;
            resultDetailInDB.ErrorMessage = detail.ErrorMessage;

            ctx.AddToResultDetails(resultDetailInDB);
        }
 /// <summary>
 /// Create a new ResultDetail object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="ruleName">Initial value of the RuleName property.</param>
 /// <param name="testResultID">Initial value of the TestResultID property.</param>
 public static ResultDetail CreateResultDetail(global::System.Int32 id, global::System.String ruleName, global::System.Int32 testResultID)
 {
     ResultDetail resultDetail = new ResultDetail();
     resultDetail.ID = id;
     resultDetail.RuleName = ruleName;
     resultDetail.TestResultID = testResultID;
     return resultDetail;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ResultDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToResultDetails(ResultDetail resultDetail)
 {
     base.AddObject("ResultDetails", resultDetail);
 }
        /// <summary>
        /// Write conformance test result to database.
        /// </summary>
        /// <param name="testResultID">The updated rule's test result ID.</param>
        /// <param name="result">The result info.</param>
        /// <param name="errorMessage">The error message.</param>
        private static void WriteToTestResult(int testResultID, string result, string errorMessage)
        {
            try
            {
                var testResult = (from j in allRulesResult
                                  where j.ID == testResultID
                                  select j).FirstOrDefault();

                if (testResult != null)
                {
                    using (var ctx = SuiteEntitiesUtility.GetODataValidationSuiteEntities())
                    {
                        var resultInTable = (from j in ctx.TestResults
                                             where j.ID == testResultID && j.ValidationJobID == testResult.ValidationJobID
                                             select j).FirstOrDefault();

                        if (resultInTable != null)
                        {
                            resultInTable.Classification = result;
                            resultInTable.ErrorMessage = errorMessage;
                            ctx.SaveChanges();

                            var detailInTable = (from j in ctx.ResultDetails
                                                 where j.TestResultID == testResultID
                                                 select j);
                            if (detailInTable != null && detailInTable.Count() > 0)
                            {
                                detailInTable.FirstOrDefault().ErrorMessage = errorMessage;
                            }
                            else
                            {
                                ResultDetail resultDetailInDB = new ResultDetail();
                                resultDetailInDB.TestResultID = resultInTable.ID;
                                resultDetailInDB.RuleName = resultInTable.RuleName;
                                resultDetailInDB.URI = "";
                                resultDetailInDB.HTTPMethod = "";
                                resultDetailInDB.RequestHeaders = "";
                                resultDetailInDB.RequestData = "";
                                resultDetailInDB.ResponseStatusCode = "";
                                resultDetailInDB.ResponseHeaders = "";
                                resultDetailInDB.ResponsePayload = "";
                                resultDetailInDB.ErrorMessage = errorMessage;
                                ctx.AddToResultDetails(resultDetailInDB);
                            }

                            ctx.SaveChanges();
                        }
                    }
                }
            }
            catch (System.Data.OptimisticConcurrencyException)
            {
                // error occurred while trying to mark operation as complete.  This is not a terminal error for this system and
                // this is on a thread-pool thread so swallow the exception
            }
        }