public void CreateMatch(IMatch match) { if (match == null) { throw new ArgumentNullException("match"); } using (CodeAnalyzerContainer context = new CodeAnalyzerContainer()) { // Mapping: Domain Model => Entity Model. Model.Match m = ToEntityModelMapper.MatchMapper(match, context); // Do the actual DB update. context.Match.Add(m); context.SaveChanges(); } }
public void CreateBulkOfMatches(List <IMatch> matches) { if (matches == null) { throw new ArgumentNullException("matches"); } // Get the overall batch identification from the Mediator. IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey); using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer()) { Model.Batch batch = new Model.Batch { TimeStamp = batchId.TimeStamp }; foreach (IMatch match in matches) { // Mapping: Domain Model => Entity Model. Model.Match m = new Model.Match() { LineNumber = match.LineNumber, CodeExtract = match.CodeExtract, RootDirectoryPath = match.RootDirectoryPath, Filename = match.Filename, Batch = batch, Status = (int)match.Result, RuleDeclaration = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx), }; // Do the actual DB update. ctx.Match.Add(m); } ctx.SaveChanges(); } }