Привет!Я создавал приложение и мне понадобилось добавить в бд данные. Вот мой код
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class PlusRecepies : Form
{
public PlusRecepies()
{
InitializeComponent();
}
private void PlusToFlp_Click(object sender, EventArgs e)
{
var label1 = new Label();
flowLayoutPanel2.Controls.Add(label1);
label1.Text = ProductPlus.Text;
}
public void AddRecipe()
{
Db1Context context = new Db1Context();
Recipe recipe = new Recipe
{
Instructions = RecepiePRText.Text,
Name = NameRecipe.Text,
Prop_Time = Convert.ToDouble(PropTime.Text)
};
context.Recipe.Add(recipe);
context.SaveChanges;
}
private void AddRecepieToDB_Click(object sender, EventArgs e)
{
AddRecipe();
}
}
}
И вот такую ошибку я получил,хоть на примере все работало.
Severity Code Description Project File Line Suppression State
Error CS0201 Only assignment, call, increment, decrement, and new object expressions can be used as a statement WindowsFormsApp1 C:\Users\user\Desktop\WindowsFormsApp1\WindowsFormsApp1\PlusRecepies.cs 38 Active