当前位置: 首页>>代码示例>>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;未经允许,请勿转载。