2

Привет!Я создавал приложение и мне понадобилось добавить в бд данные. Вот мой код

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

1 ответ 1

4

SaveChanges - это метод. Так что context.SaveChanges();

2
  • Ошибки нету теперь))))) 5 мар 2018 в 13:01
  • @OleksandrTatarinov выдели как правильный ответ
    – Tivyram
    5 мар 2018 в 13:05

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.