public override Conference Delete(Conference conf) { this.CheckEntityForNull(conf, typeof(Conference)); using (var ts = new TransactionScope(TransactionScopeOption.Required)) { this.EnsureContext(); this.context.EnlistTransaction(); var attendees = conf.Attendees; if (attendees != null && attendees.Count > 0) { var p = new SqlParameter("@confId", conf.Id); var parameters = new List <IDataParameter> { #pragma warning disable IDE0009 // Member access should be qualified. p #pragma warning restore IDE0009 // Member access should be qualified. }; this.ExecuteNonQuery("delete from dbo.ConferenceUser where conferenceId=@confId", parameters); } var articleMapper = new ArticleMapper(this.context); foreach (var a in this.LoadArticles(conf)) { articleMapper.Delete(a); } var del = base.Delete(conf); ts.Complete(); return(del); } }
internal List <Article> LoadArticles(Author author) { var articles = new List <Article>(); var mapper = new ArticleMapper(this.context); var parameters = new List <IDataParameter> { #pragma warning disable IDE0009 // Member access should be qualified. new SqlParameter("@id", author.Id) #pragma warning restore IDE0009 // Member access should be qualified. }; using (var reader = this.ExecuteReader("select articleId from ArticleAuthor where authorId = @id", parameters)) { while (reader.Read()) { articles.Add(mapper.Read(reader.GetInt32(0))); } } return(articles); }