/// <summary> /// Hard-coded sample for getting comments for a property. In this case /// in <see cref="ProductsConfiguration"/> the following sets the comment for ProductName /// /// entity.Property(e => e.ProductName).HasComment("Product name"); /// /// For use in an application add a parameter for class name e.g. Products /// and another parameter for property name e.g. ProductName. Then change the return /// type to string. /// /// Another version would return list of <see cref="ModelComment"/> while using a parameter for class name /// </summary> public static void Comments() { using var context = new NorthwindContext(); var comments = context.Comments("Products"); Debug.WriteLine(comments.FirstOrDefault(product => product.Name == "ProductName").Comment); }
private void GetCommentsButton_Click(object sender, EventArgs e) { using (var context = new NorthwindContext()) { var comments = context.Comments(ModelNamesListBox.Text).Select(x => x.Full).ToList(); var commentForm = new ModelCommentsForm(comments, ModelNamesListBox.Text); try { commentForm.ShowDialog(); } finally { commentForm.Dispose(); } } }