public virtual ICriterion Delete(ICriterion criterion, IContext context) { Criterion item = new Criterion(); if (criterion != null) { if (DbConnection != null) { IRequestContext ctx = context as IRequestContext; //ISqlCommandContext<T> resolver = (ISqlCommandContext<T>)this; SqlCommand cmd = null; int i = 0; using (SqlConnection cn = DbConnection) { try { cn.Open(); cmd = DeleteSqlCommand(cn, criterion, context); if (cmd != null) { if (eXtensibleConfig.CaptureMetrics) { ctx.SetMetric(cmd.CommandType.ToString(), XFConstants.Metrics.Database.Command, cmd.CommandText); ctx.SetMetric(XFConstants.Metrics.Scope.DataStore, XFConstants.Metrics.Scope.Command.Begin, DateTime.Now); } i = cmd.ExecuteNonQuery(); bool b = (i == 1) ? true : false; item.AddItem("Success", b); if (eXtensibleConfig.CaptureMetrics) { ctx.SetMetric(XFConstants.Metrics.Scope.DataStore, XFConstants.Metrics.Scope.Command.End, DateTime.Now); ctx.SetMetric(XFConstants.Metrics.Scope.DataStore, XFConstants.Metrics.Count, i); } } else { var message = Exceptions.ComposeNullSqlCommand <T>(ModelActionOption.Delete, null, criterion, context, this.GetType().FullName); context.SetError(500, message.ToPublish()); EventWriter.WriteError(message.ToLog(), SeverityType.Error, XFConstants.Category.DataAccess, context.ToDictionary(message.Id)); } } catch (Exception ex) { if (eXtensibleConfig.CaptureMetrics) { ctx.SetMetric(XFConstants.Metrics.Scope.DataStore, XFConstants.Metrics.Scope.Command.End, DateTime.Now); } string database = String.Format("server:{0};database:{1}", cn.DataSource, cn.Database); var message = Exceptions.ComposeSqlException <T>(ModelActionOption.Delete, ex, null, criterion, context, this.GetType().FullName, database); context.SetError(500, message.ToPublish()); context.SetStacktrace(ex.StackTrace); EventWriter.WriteError(message.ToLog(), SeverityType.Error, XFConstants.Category.DataAccess, context.ToDictionary(message.Id)); } } } } else if (eXtensibleConfig.Inform) { EventWriter.Inform(String.Format("No criterion was provided for {0}.Delete method in {1}", GetModelType().FullName, this.GetType().FullName)); } return(item); }