當前位置: 首頁>>代碼示例>>C#>>正文


C# testEntities.AddToAuthors方法代碼示例

本文整理匯總了C#中MySql.Data.Entity.Tests.testEntities.AddToAuthors方法的典型用法代碼示例。如果您正苦於以下問題:C# testEntities.AddToAuthors方法的具體用法?C# testEntities.AddToAuthors怎麽用?C# testEntities.AddToAuthors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MySql.Data.Entity.Tests.testEntities的用法示例。


在下文中一共展示了testEntities.AddToAuthors方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Insert

    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"]);
    }
開發者ID:brunolauze,項目名稱:mysql-connector-net-6,代碼行數:22,代碼來源:ProceduresAndFunctions.cs

示例2: CommandTimeout

        public void CommandTimeout()
        {
            string connectionString = String.Format(
              "metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=MySql.Data.MySqlClient; provider connection string=\"{0};default command timeout=5\"", GetConnectionString(true));
              EntityConnection connection = new EntityConnection(connectionString);

              using (testEntities context = new testEntities(connection))
              {
            Author a = new Author();
            a.Id = 66;  // special value to indicate the routine should take 30 seconds
            a.Name = "Test name";
            a.Age = 44;
            context.AddToAuthors(a);
            try
            {
              context.SaveChanges();
              Assert.Fail("This should have timed out");
            }
            catch (Exception ex)
            {
              string s = ex.Message;
            }
              }
        }
開發者ID:schivei,項目名稱:mysql-connector-net,代碼行數:24,代碼來源:ProceduresAndFunctions.cs

示例3: DefaultCommandTimeOutNotWorking

        public void DefaultCommandTimeOutNotWorking()
        {
            string connectionString = String.Format(
              "metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=MySql.Data.MySqlClient; provider connection string=\"{0};Use Default Command Timeout For EF=true; Default Command Timeout=5;\"", GetConnectionString(true));
              //EntityConnection connection = new EntityConnection(connectionString);

              using (testEntities context = new testEntities(connectionString))
              {
            Author a = new Author();
            a.Id = 66;  // special value to indicate the routine should take 30 seconds
            a.Name = "Test name";
            a.Age = 44;
            context.AddToAuthors(a);
            try
            {
              context.SaveChanges();
              Assert.Fail("This should have timed out");
            }
            catch (Exception ex)
            {
              Exception innerException = ex.InnerException;
              Assert.AreEqual("Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.", innerException.Message);
            }
              }
        }
開發者ID:schivei,項目名稱:mysql-connector-net,代碼行數:25,代碼來源:ProceduresAndFunctions.cs


注:本文中的MySql.Data.Entity.Tests.testEntities.AddToAuthors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。