Beispiel #1
0
        private static void OnCreateArticle(object?sender, CreateArticleEventArgs e)
        {
            using var db = new BloggingContext();
            var commentCollection = new CommentCollection();

            db.CommentCollections.Add(commentCollection);
            db.SaveChanges();
            e.Article.CommentCollection = commentCollection;
        }
Beispiel #2
0
        private static void OnCreateArticle(object?sender, CreateArticleEventArgs e)
        {
            using var db = new BloggingContext();
            var articleVersion = new ArticleVersion
            {
                VersionNumber = 1,
                VersionNote   = "Initial",
                Status        = "published"
            };

            db.ArticleVersions.Add(articleVersion);
            db.SaveChanges();
            e.Article.ArticleVersionId = articleVersion.Id;
        }