• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Tests.testEntities类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MySql.Data.Entity.Tests.testEntities的典型用法代码示例。如果您正苦于以下问题:C# testEntities类的具体用法?C# testEntities怎么用?C# testEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



testEntities类属于MySql.Data.Entity.Tests命名空间,在下文中一共展示了testEntities类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateDatabaseScript

 public void CreateDatabaseScript()
 {
     using (testEntities ctx = new testEntities())
     {
         string s = ctx.CreateDatabaseScript();
     }
 }
开发者ID:LittlePeng,项目名称:ncuhome,代码行数:7,代码来源:ProviderServicesTests.cs


示例2: AverageWithGrouping

        public void AverageWithGrouping()
        {
            MySqlDataAdapter da = new MySqlDataAdapter(
              "SELECT AVG(Freight) FROM Orders GROUP BY ShopId", conn);
              DataTable dt = new DataTable();
              da.Fill(dt);

              using (testEntities context = new testEntities())
              {
            string eSql = "SELECT AVG(o.Freight) FROM Orders AS o GROUP BY o.Shop.Id";
            ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(eSql);

            string sql = q.ToTraceString();
            CheckSql(sql, SQLSyntax.AverageWithGrouping);

            foreach (object x in q)
            {
              string s = x.GetType().ToString();
            }
            int i = 0;
            foreach (var freight in q)
            {
              //   Assert.AreEqual(Convert.ToInt32(dt.Rows[i++][0]), Convert.ToInt32(freight));
            }
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:26,代码来源:AggregateOperators.cs


示例3: DoubleValuesNonEnglish

        public void DoubleValuesNonEnglish()
        {
            CultureInfo curCulture = Thread.CurrentThread.CurrentCulture;
              CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture;
              CultureInfo newCulture = new CultureInfo("da-DK");
              Thread.CurrentThread.CurrentCulture = newCulture;
              Thread.CurrentThread.CurrentUICulture = newCulture;

              try
              {
            using (testEntities context = new testEntities())
            {
              Child c = new Child();
              c.Id = 20;
              c.EmployeeID = 1;
              c.FirstName = "Bam bam";
              c.LastName = "Rubble";
              c.BirthWeight = 8.65;
              c.Modified = DateTime.Now;
              context.AddToChildren(c);
              context.SaveChanges();
            }
              }
              finally
              {
            Thread.CurrentThread.CurrentCulture = curCulture;
            Thread.CurrentThread.CurrentUICulture = curUICulture;
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:29,代码来源:DataTypeTests.cs


示例4: SimpleJoinWithPredicate

    public void SimpleJoinWithPredicate()
    {
      MySqlDataAdapter da = new MySqlDataAdapter(
          @"SELECT b.id,b.name,a.name as author_name from books b JOIN
                    authors a ON b.author_id=a.id WHERE b.pages > 300", conn);
      DataTable dt = new DataTable();
      da.Fill(dt);

      using (testEntities context = new testEntities())
      {
        var q = from b in context.Books
                join a in context.Authors
                on b.Author.Id equals a.Id
                where b.Pages > 300
                select new
                {
                  bookId = b.Id,
                  bookName = b.Name,
                  authorName = a.Name
                };

        string sql = q.ToTraceString();
        CheckSql(sql, SQLSyntax.SimpleJoinWithPredicate);

        int i = 0;
        foreach (var o in q)
          Assert.AreEqual(dt.Rows[i++][0], o.bookId);
        Assert.AreEqual(dt.Rows.Count, i);
      }
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:30,代码来源:JoinTests.cs


示例5: ConversionToLike

 public void ConversionToLike()
 {
     // Generates queries for each LIKE + wildcards case and checks SQL generated.
       using (testEntities ctx = new testEntities())
       {
     // Like 'pattern%'
     var q = from c in ctx.Employees where c.FirstName.StartsWith( "B" )
         orderby c.FirstName select c;
     string query = q.ToTraceString();
     CheckSql(query, SQLSyntax.StartsWithTranslatedToLike);
     Assert.AreEqual(2, q.Count());
     Assert.AreEqual("Barney", q.First().FirstName);
     Assert.AreEqual("Betty", q.Skip(1).First().FirstName);
     // Like '%pattern%'
     q = from c in ctx.Employees where c.FirstName.Contains("r")
     orderby c.FirstName select c;
     query = q.ToTraceString();
     CheckSql(query, SQLSyntax.ContainsTranslatedToLike);
     Assert.AreEqual(2, q.Count());
     Assert.AreEqual("Barney", q.First().FirstName);
     Assert.AreEqual("Fred", q.Skip(1).First().FirstName);
     // Like '%pattern'
     q = from c in ctx.Employees
         where c.FirstName.EndsWith("y")
         orderby c.FirstName
         select c;
     query = q.ToTraceString();
     CheckSql(query, SQLSyntax.EndsWithTranslatedToLike);
     Assert.AreEqual(3, q.Count());
     Assert.AreEqual("Barney", q.First().FirstName);
     Assert.AreEqual("Betty", q.Skip(1).First().FirstName);
     Assert.AreEqual("Scooby", q.Skip(2).First().FirstName);
       }
 }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:34,代码来源:CanonicalFunctions.cs


示例6: CanGroupByMultipleColumns

        public void CanGroupByMultipleColumns()
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter(
              "SELECT Name, COUNT(Id) as Count FROM Companies GROUP BY Name, NumEmployees, DateBegan", conn);
              DataTable table = new DataTable();
              adapter.Fill(table);

              using (testEntities context = new testEntities())
              {
            var companies = from c in context.Companies
                        group c by new { c.Name, c.NumEmployees, c.DateBegan } into cgroup
                        select new
                        {
                          Name = cgroup.Key.Name,
                          Count = cgroup.Count()
                        };

            string sql = companies.ToTraceString();
            CheckSql(sql, SQLSyntax.CanGroupByMultipleColumns);

            int i = 0;
            foreach (var company in companies)
            {
              Assert.AreEqual(table.Rows[i][0], company.Name);
              Assert.AreEqual(table.Rows[i][1], company.Count);
              i++;
            }
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:29,代码来源:OrderingAndGrouping.cs


示例7: SimpleJoin

        public void SimpleJoin()
        {
            MySqlDataAdapter da = new MySqlDataAdapter(
                @"SELECT b.id,b.name,a.name as author_name from books b JOIN
                    authors a ON b.author_id=a.id", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);

            using (testEntities context = new testEntities())
            {
                var q = from b in context.Books
                        join a in context.Authors
                        on b.Author.Id equals a.Id
                        select new
                        {
                            bookId = b.Id,
                            bookName = b.Name,
                            authorName = a.Name
                        };

                int i = 0;
                foreach (var o in q)
                    Assert.AreEqual(dt.Rows[i++][0], o.bookId);
                Assert.AreEqual(dt.Rows.Count, i);
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:26,代码来源:JoinTests.cs


示例8: JoinOfNestedUnionsWithLimit

        public void JoinOfNestedUnionsWithLimit()
        {
            using (testEntities context = new testEntities())
              {
            var q = context.Books.Include("Author");
            q = q.Include("Publisher");
            q = q.Include("Publisher.Books");
            string sql = q.ToTraceString();

            var  i = 0;
            foreach (var o in q.Where(p => p.Id > 0).OrderBy(p => p.Name).ThenByDescending(p => p.Id).Skip(0).Take(32).ToList())
            {
               switch (i)
              {
             case 0:
               Assert.AreEqual(5, o.Id);
               Assert.AreEqual("Debt of Honor", o.Name);
             break;
             case 1:
               Assert.AreEqual(1, o.Id);
               Assert.AreEqual("Debt of Honor", o.Name);
             break;
             case 4:
               Assert.AreEqual(3, o.Id);
               Assert.AreEqual("Rainmaker", o.Name);
             break;
              }
               i++;
            }
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:31,代码来源:JoinTests.cs


示例9: UnsignedValues

 public void UnsignedValues()
 {
     using (testEntities context = new testEntities())
     {
         var row = context.Children.First();
         context.Detach(row);
         context.Attach(row);
     }
 }
开发者ID:LittlePeng,项目名称:ncuhome,代码行数:9,代码来源:DataTypeTests.cs


示例10: FirstSimple

        public void FirstSimple()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT id FROM orders", conn);
            int id = (int)cmd.ExecuteScalar();

            using (testEntities context = new testEntities())
            {
                var q = from o in context.Orders 
                            select o;
                Order order = q.First() as Order;
                Assert.AreEqual(id, order.Id);
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:13,代码来源:SetOperators.cs


示例11: FirstPredicate

    public void FirstPredicate()
    {
      MySqlCommand cmd = new MySqlCommand("SELECT id FROM orders WHERE freight > 100", conn);
      int id = (int)cmd.ExecuteScalar();

      using (testEntities context = new testEntities())
      {
        var q = from o in context.Orders
                where o.Freight > 100
                select o;
        Order order = q.First() as Order;
        Assert.AreEqual(id, order.Id);
      }
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:14,代码来源:SetOperators.cs


示例12: BigCountSimple

        public void BigCountSimple()
        {
            MySqlCommand trueCmd = new MySqlCommand("SELECT COUNT(*) FROM Toys", conn);
            object trueCount = trueCmd.ExecuteScalar();

            using (testEntities context = new testEntities())
            {
                string sql = "SELECT VALUE BigCount(t.Id) FROM Toys AS t";
                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);

                foreach (int count in q)
                    Assert.AreEqual(trueCount, count);
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:14,代码来源:AggregateOperators.cs


示例13: CanInsertRowWithDefaultTimeStamp

        public void CanInsertRowWithDefaultTimeStamp()
        {
            using (testEntities context = new testEntities())
              {
            // The default timestamp is in the CreatedDate column.
            Product product = new Product();
            product.Name = "Coca Cola";

            context.AddToProducts(product);
            context.SaveChanges();

            Assert.AreEqual(DateTime.Today.Day, product.CreatedDate.Day);
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:14,代码来源:InsertTests.cs


示例14: YearMonthDay

 public void YearMonthDay()
 {
     using (testEntities context = new testEntities())
     {
         ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(
             @"SELECT c.DateBegan, Year(c.DateBegan), Month(c.DateBegan), Day(c.DateBegan)
                 FROM Companies AS c WHERE c.Id=1");
         foreach (DbDataRecord record in q)
         {
             Assert.AreEqual(1996, record[1]);
             Assert.AreEqual(11, record[2]);
             Assert.AreEqual(15, record[3]);
         }
     }
 }
开发者ID:LittlePeng,项目名称:ncuhome,代码行数:15,代码来源:CanonicalFunctions.cs


示例15: Bitwise

 public void Bitwise()
 {
   using (testEntities context = new testEntities())
   {
     ObjectQuery<Int32> q = context.CreateQuery<Int32>("BitwiseAnd(255,15)");
     foreach (int i in q)
       Assert.AreEqual(15, i);
     q = context.CreateQuery<Int32>("BitwiseOr(240,31)");
     foreach (int i in q)
       Assert.AreEqual(255, i);
     q = context.CreateQuery<Int32>("BitwiseXor(255,15)");
     foreach (int i in q)
       Assert.AreEqual(240, i);
   }
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:15,代码来源:CanonicalFunctions.cs


示例16: SimpleSelectWithFilter

        public void SimpleSelectWithFilter()
        {
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Toys WHERE minage=4", conn);
            DataTable toys = new DataTable();
            da.Fill(toys);
            int i = 0;

            using (testEntities context = new testEntities())
            {
                var query = context.CreateQuery<Toy>("SELECT VALUE t FROM Toys AS t WHERE t.MinAge=4");
                foreach (Toy t in query)
                {
                    Assert.AreEqual(toys.Rows[i++]["name"], t.Name);
                }
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:16,代码来源:RestrictionOperators.cs


示例17: Distinct

        public void Distinct()
        {
            using (testEntities context = new testEntities())
              {
            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Companies LIMIT 2", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);

            int i = 0;
            var query = context.Companies.Top("2");
            foreach (Company c in query)
            {
              Assert.AreEqual(dt.Rows[i++]["id"], c.Id);
            }
              }
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:16,代码来源:SetOperators.cs


示例18: SimpleDeleteAllRows

        public void SimpleDeleteAllRows()
        {
            using (testEntities context = new testEntities())
            {
                foreach (Toy t in context.Toys)
                    context.DeleteObject(t);
                context.SaveChanges();

                EntityConnection ec = context.Connection as EntityConnection;
                MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM toys",
                    (MySqlConnection)ec.StoreConnection);
                DataTable dt = new DataTable();
                da.Fill(dt);
                Assert.AreEqual(0, dt.Rows.Count);
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:16,代码来源:DeleteTests.cs


示例19: UpdateAllRows

    public void UpdateAllRows()
    {
      MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM toys", conn);
      object count = cmd.ExecuteScalar();

      using (testEntities context = new testEntities())
      {
        foreach (Toy t in context.Toys)
          t.Name = "Top";
        context.SaveChanges();
      }

      cmd.CommandText = "SELECT COUNT(*) FROM Toys WHERE name='Top'";
      object newCount = cmd.ExecuteScalar();
      Assert.AreEqual(count, newCount);
    }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:16,代码来源:UpdateTests.cs


示例20: CurrentDateTime

    public void CurrentDateTime()
    {
      DateTime current = DateTime.Now;

      using (testEntities context = new testEntities())
      {
        ObjectQuery<DateTime> q = context.CreateQuery<DateTime>("CurrentDateTime()");
        foreach (DateTime dt in q)
        {
          Assert.AreEqual(current.Year, dt.Year);
          Assert.AreEqual(current.Month, dt.Month);
          Assert.AreEqual(current.Day, dt.Day);
          // we don't check time as that will be always be different
        }
      }
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:16,代码来源:CanonicalFunctions.cs



注:本文中的MySql.Data.Entity.Tests.testEntities类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MySqlClient.MySqlCommand类代码示例发布时间:2022-05-26
下一篇:
C# dOOdads.WhereParameter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap