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


C# Query.Close方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: AddManyToMany

    //void cal_SelectionChanged(object sender, EventArgs e)
    //{
    //    CalendarControl cal = (CalendarControl)sender;
    //    ViewState.Add("vs" + cal.ID, cal.SelectedDate.Date);
    //    //throw new Exception("The method or operation is not implemented.");
    //}
    /// <summary>
    /// 
    /// </summary>
    /// <param name="isEdit"></param>
    /// <param name="table"></param>
    private void AddManyToMany(bool isEdit, HtmlTable table)
    {
        string[] mmTables = _manyToManyMap.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

        if (mmTables.Length > 0)
        {
            foreach (string mmTableName in mmTables)
            {
                TableSchema.Table mmTable = Query.BuildTableSchema(mmTableName);

                //this table should have one or more primary keys
                //one of these keys should, by convention, have the same name
                //as the primary key of our main schema table
                //need to get this key, then find it's table
                foreach (TableSchema.TableColumn col in mmTable.Columns)
                {
                    if (col.IsPrimaryKey && col.ColumnName.ToLower() != Schema.PrimaryKey.ColumnName.ToLower())
                    {
                        //this is the key we need. Get the table for this key
                        string fTableName = DataService.GetForeignKeyTableName(col.ColumnName, mmTableName, ProviderName);

                        if (fTableName != string.Empty && isEdit)
                        {
                            CheckBoxList chk = new CheckBoxList();
                            chk.ID = mmTableName;
                            //add the checkbox in
                            AddRow(table, Utility.ParseCamelToProper(mmTableName), chk);
                            chk.RepeatColumns = 2;

                            TableSchema.Table fTable = Query.BuildTableSchema(fTableName);
                            Query qry = new Query(fTable);
                            IDataReader rdr = qry.ExecuteReader();

                            while (rdr.Read())
                            {
                                chk.Items.Add(new ListItem(rdr[1].ToString(), rdr[0].ToString()));
                            }

                            rdr.Close();
                            //now we need to query the map table, loop it, and check off the items
                            //that are in it

                            object pk = Context.Request.QueryString["id"];

                            rdr = new Query(mmTable).AddWhere(Schema.PrimaryKey.ColumnName, pk).ExecuteReader();

                            //thanks to jcoenen for this!
                            while (rdr.Read())
                            {
                                string fkID = rdr[fTable.PrimaryKey.ColumnName].ToString();
                                foreach (ListItem item in chk.Items)
                                {
                                    if (item.Value.ToLower().Equals(fkID.ToLower()))
                                    {
                                        item.Selected = true;
                                        break;
                                    }

                                }

                            }
                            rdr.Close();

                        }
                    }
                }
            }
        }
    }
开发者ID:hondoslack,项目名称:territorysite,代码行数:80,代码来源:AutoScaffold.aspx.cs


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