MySql.Data.Entity.Tests.testEntities.AddToAuthors C# (CSharp) Méthode

AddToAuthors() public méthode

Deprecated Method for adding a new object to the Authors EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead.
public AddToAuthors ( Author author ) : void
author Author
Résultat void
        public void AddToAuthors(Author author)
        {
            base.AddObject("Authors", author);
        }
    

Usage Example

    public void Insert()
    {
      MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Authors", conn);
      DataTable dt = new DataTable();
      da.Fill(dt);
      int count = dt.Rows.Count;

      using (testEntities context = new testEntities())
      {
        Author a = new Author();
        a.Id = 23;
        a.Name = "Test name";
        a.Age = 44;
        context.AddToAuthors(a);
        context.SaveChanges();
      }

      dt.Clear();
      da.Fill(dt);
      Assert.AreEqual(count + 1, dt.Rows.Count);
      Assert.AreEqual(23, dt.Rows[count]["id"]);
    }
All Usage Examples Of MySql.Data.Entity.Tests.testEntities::AddToAuthors