当前位置: 首页>>代码示例>>C#>>正文


C# Query.Read方法代码示例

本文整理汇总了C#中Query.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Query.Read方法的具体用法?C# Query.Read怎么用?C# Query.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Query_OR_ModerateWithExpressions

 public void Query_OR_ModerateWithExpressions()
 {
     int counter = 0;
     using(
         IDataReader rdr =
             new Query("Products").WHERE("CategoryID = 5").AND("UnitPrice > 50").OR("CategoryID = 1").AND(
                 "UnitPrice > 50").ExecuteReader())
     {
         while(rdr.Read())
             counter++;
     }
     Assert.AreEqual(5, counter, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:13,代码来源:QueryTest.cs

示例2: Query_OR_Between

        public void Query_OR_Between()
        {
            int counter = 0;
            string[] sFormat = {"M/d/yyyy"};

            using(IDataReader rdr =
                new Query("Orders").BETWEEN_AND("OrderDate",
                    DateTime.ParseExact("7/4/1996", sFormat, CultureInfo.CurrentCulture, DateTimeStyles.None),
                    DateTime.ParseExact("7/10/1996", sFormat, CultureInfo.CurrentCulture, DateTimeStyles.None)).OR_BETWEEN_AND("OrderDate",
                        DateTime.ParseExact("7/14/1996", sFormat, CultureInfo.CurrentCulture, DateTimeStyles.None),
                        DateTime.ParseExact("7/20/1996", sFormat, CultureInfo.CurrentCulture, DateTimeStyles.None)).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }

            //should bring back all records
            Assert.IsTrue(counter == 12, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:20,代码来源:QueryTest.cs

示例3: Query_OR_Simple

 public void Query_OR_Simple()
 {
     int counter = 0;
     using(IDataReader rdr = new Query("Categories").WHERE("CategoryID", 5).OR("CategoryID", 1).ExecuteReader())
     {
         while(rdr.Read())
             counter++;
         rdr.Close();
     }
     //should bring back all records
     Assert.IsTrue(counter == 2, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例4: Query_OR_Moderate

        public void Query_OR_Moderate()
        {
            int counter = 0;
            using(
                IDataReader rdr =
                    new Query("Products").WHERE("CategoryID", 5).AND("UnitPrice", Comparison.GreaterThan, 50).OR("CategoryID", 1).AND("UnitPrice", Comparison.GreaterThan, 50).
                        ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
            }

            Assert.AreEqual(5, counter, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:14,代码来源:QueryTest.cs

示例5: Query_NOT_IN_ArrayList

        public void Query_NOT_IN_ArrayList()
        {
            ArrayList list = new ArrayList();
            for(int i = 1; i <= 5; i++)
                list.Add(i);

            int counter = 0;
            using(IDataReader rdr = new Query("products").NOT_IN("ProductID", list).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == 72, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:15,代码来源:QueryTest.cs

示例6: Query_IsNotNull

 public void Query_IsNotNull()
 {
     int counter = 0;
     using(IDataReader rdr = new Query("Products").AddWhere("ProductID", Comparison.IsNot, null).ExecuteReader())
     {
         while(rdr.Read())
             counter++;
         rdr.Close();
     }
     //should bring back all records
     Assert.AreEqual(new Query(Product.Schema).GetCount(Product.Columns.ProductID), counter, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例7: Query_NOT_IN_ObjectArray

        public void Query_NOT_IN_ObjectArray()
        {
            int counter = 0;

            using(IDataReader rdr = new Query("products").NOT_IN("ProductID", new object[] {1, 2, 3, 4, 5}).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == 72, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例8: Acc_Query_NOT_IN_ArrayList

        public void Acc_Query_NOT_IN_ArrayList()
        {
            int productCount = new Query(Product.Schema).GetRecordCount();

            ArrayList list = new ArrayList();
            for(int i = 1; i <= 5; i++)
                list.Add(i);

            int counter = 0;
            using (IDataReader rdr = new Query("products", "NorthwindAccess").NOT_IN("ProductID", list).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == productCount - 5, "Nope - it's " + counter);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:17,代码来源:QueryTest.cs

示例9: Query_View

 public void Query_View()
 {
     int counter = 0;
     using(
         IDataReader rdr = new Query(DataService.GetTableSchema("Invoices", DataService.Provider.Name)).AddWhere("ShipPostalCode", "51100").ExecuteReader())
     {
         while(rdr.Read())
             counter++;
         rdr.Close();
     }
     Assert.IsTrue(counter == 10, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例10: Query_BetweenNumbers

        public void Query_BetweenNumbers()
        {
            int counter = 0;

            using(IDataReader rdr = new Query(Product.Schema).AddBetweenValues("productID", 1, 7).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == 7, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例11: Query_BetweenAnd

 public void Query_BetweenAnd()
 {
     int counter = 0;
     using(
         IDataReader rdr =
             new Query(DataService.GetTableSchema("Orders", DataService.Provider.Name)).AddBetweenAnd("OrderDate", new DateTime(1996, 7, 4), new DateTime(1996, 7, 16)).
                 ExecuteReader())
     {
         while(rdr.Read())
             counter++;
         rdr.Close();
     }
     Assert.IsTrue(counter == 10, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:14,代码来源:QueryTest.cs

示例12: Acc_Query_NOT_IN_ObjectArray

        public void Acc_Query_NOT_IN_ObjectArray()
        {
            int counter = 0;
            int productCount = new Query(Product.Schema).GetRecordCount();

            using (IDataReader rdr = new Query("products", "NorthwindAccess").NOT_IN("ProductID", new object[] { 1, 2, 3, 4, 5 }).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == productCount-5, "Nope - it's " + counter);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:13,代码来源:QueryTest.cs

示例13: Acc_Query_NOT_IN_ListCollection

        public void Acc_Query_NOT_IN_ListCollection()
        {
            int productCount = new Query(Product.Schema).GetRecordCount();

            ListItemCollection coll = new ListItemCollection();
            for(int i = 1; i <= 5; i++)
            {
                ListItem item = new ListItem(i.ToString(), i.ToString());
                item.Selected = true;
                coll.Add(item);
            }

            int counter = 0;
            using (IDataReader rdr = new Query("products", "NorthwindAccess").NOT_IN("ProductID", coll).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == productCount - 5, "Nope - it's " + counter);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:21,代码来源:QueryTest.cs

示例14: Query_Expression

 public void Query_Expression()
 {
     int counter = 0;
     using(IDataReader rdr = new Query("Products", "Northwind").WHERE("ProductID < 5").ExecuteReader())
     {
         while(rdr.Read())
             counter++;
         rdr.Close();
     }
     //should bring back all records
     Assert.IsTrue(counter == 4, "Nope - it's " + counter);
 }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例15: Query_NOT_IN_ListCollection

        public void Query_NOT_IN_ListCollection()
        {
            ListItemCollection coll = new ListItemCollection();
            for(int i = 1; i <= 5; i++)
            {
                ListItem item = new ListItem(i.ToString(), i.ToString());
                item.Selected = true;
                coll.Add(item);
            }

            int counter = 0;
            using(IDataReader rdr = new Query("products").NOT_IN("ProductID", coll).ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.IsTrue(counter == 72, "Nope - it's " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:19,代码来源:QueryTest.cs


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