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


C# Query.ExecuteDataSet方法代码示例

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


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

示例1: TestXMLResultStringZeroRecords

 public void TestXMLResultStringZeroRecords()
 {
     Query q = new Query(Product.Schema).WHERE(Product.Columns.ProductID, int.MaxValue);
     DataSet ds = q.ExecuteDataSet();
     string result = handler.FormatOutput(ds);
     string expectedResult = "<Products><Product/></Products>";
     Assert.AreEqual(expectedResult, result);
 }
开发者ID:daveneeley,项目名称:SubSonic-2.0,代码行数:8,代码来源:RESTHandlerTests.cs

示例2: TestXMLResultStringSingleRecord

 public void TestXMLResultStringSingleRecord()
 {
     Query q = new Query(Product.Schema).WHERE(Product.Columns.ProductID, 1);
     DataSet ds = q.ExecuteDataSet();
     string result = handler.FormatOutput(ds);
     string expectedResult = "<Products>\r\n  <Product>\r\n    <ProductID>1</ProductID>\r\n    <ProductName>Chai</ProductName>\r\n    <SupplierID>16</SupplierID>\r\n    <CategoryID>1</CategoryID>\r\n    <QuantityPerUnit>10 boxes x 20 bags</QuantityPerUnit>\r\n    <UnitPrice>50.0000</UnitPrice>\r\n    <UnitsInStock>39</UnitsInStock>\r\n    <UnitsOnOrder>0</UnitsOnOrder>\r\n    <ReorderLevel>10</ReorderLevel>\r\n    <Discontinued>false</Discontinued>\r\n    <AttributeXML>&lt;ArrayOfProductAttribute xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"&gt;&lt;ProductAttribute&gt;&lt;AttributeName&gt;Test1&lt;/AttributeName&gt;&lt;AttributeValue xsi:type=\"xsd:string\"&gt;String Value&lt;/AttributeValue&gt;&lt;CurrencyOffset&gt;12&lt;/CurrencyOffset&gt;&lt;/ProductAttribute&gt;&lt;ProductAttribute&gt;&lt;AttributeName&gt;Test2&lt;/AttributeName&gt;&lt;AttributeValue xsi:type=\"xsd:dateTime\"&gt;2007-03-09T10:42:00.6517547-10:00&lt;/AttributeValue&gt;&lt;CurrencyOffset&gt;-100&lt;/CurrencyOffset&gt;&lt;/ProductAttribute&gt;&lt;/ArrayOfProductAttribute&gt;</AttributeXML>\r\n    <DateCreated>2007-05-22T19:44:42-06:00</DateCreated>\r\n    <ProductGUID>52c7760f-6b66-46e7-a99b-67cf142f2a6c</ProductGUID>\r\n    <CreatedOn>2007-05-22T19:43:04-06:00</CreatedOn>\r\n    <ModifiedOn>2007-05-24T06:31:51-06:00</ModifiedOn>\r\n    <ModifiedBy>Unit Test</ModifiedBy>\r\n    <Deleted>false</Deleted>\r\n  </Product>\r\n</Products>";
     Assert.AreEqual(expectedResult, result);
 }
开发者ID:daveneeley,项目名称:SubSonic-2.0,代码行数:8,代码来源:RESTHandlerTests.cs

示例3: Multi_QueryTest

        public void Multi_QueryTest()
        {
            //hit both the Northwind and Southwind databases
            Query query1 = new Query("Products", "Northwind");
            DataSet ds1 = query1.ExecuteDataSet();
            Assert.IsTrue(ds1.Tables[0].Rows.Count > 0);

            Query query2 = new Query("Products", "Southwind");
            DataSet ds2 = query2.ExecuteDataSet();
            Assert.IsTrue(ds2.Tables[0].Rows.Count > 0);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:11,代码来源:MultiProvider.cs

示例4: Testing_Pagination

        public void Testing_Pagination()
        {
            //Query q = new Query("select * from tblreview where deleted=0");
            //Query q = new Query("tblReview");

            Query q = new Query("tblreview").WHERE("deleted=false");

            q.PageSize = 10;
            q.PageIndex = 3;
            DataRowCollection rows = q.ExecuteDataSet().Tables[0].Rows;

            //IList<AnimalsTaxa> at = SignificantTradeSSRepository.DB.Select().From<AnimalsTaxa>().ExecuteTypedList<AnimalsTaxa>();
            Assert.AreEqual(rows[0][0].ToString(),"hello");
        }
开发者ID:unepwcmc,项目名称:sigtrade,代码行数:14,代码来源:MeetingLibTest.cs

示例5: GenerateReturnSet

        /// <summary>
        /// Data retrieval
        /// </summary>
        /// <returns></returns>
        private DataSet GenerateReturnSet()
        {
            DataSet result = null;

            if(_url != null)
            {
                Query q;

                if(!String.IsNullOrEmpty(_url.TableName))
                {
                    q = new Query(_url.TableName);
                    TableSchema.Table schema = q.Schema;

                    if(_url.PrimaryKey != null)
                        q.WHERE(q.Schema.PrimaryKey.ParameterName, _url.PrimaryKey);

                    if(_url.Parameters != null)
                    {
                        IDictionaryEnumerator loopy = _url.Parameters.GetEnumerator();
                        TableSchema.TableColumn column;

                        string paramName;
                        object paramValue;

                        while(loopy.MoveNext())
                        {
                            paramName = loopy.Key.ToString();
                            paramValue = loopy.Value;

                            if(paramName.ToLowerInvariant() == "pagesize" || paramName.ToLowerInvariant() == "pageindex")
                            {
                                if(paramName.ToLowerInvariant() == "pagesize")
                                    q.PageSize = int.Parse(paramValue.ToString());

                                if(paramName.ToLowerInvariant() == "pageindex")
                                    q.PageIndex = int.Parse(paramValue.ToString());
                            }
                            else
                            {
                                Comparison comp;
                                EvalComparison(paramName, out paramName, out comp);
                                column = schema.GetColumn(paramName);

                                //if this column is a string, by default do a fuzzy search
                                if(comp == Comparison.Like || column.IsString)
                                {
                                    comp = Comparison.Like;
                                    paramValue = String.Concat("%", paramValue, "%");
                                }
                                else if(paramValue.ToString().ToLower() == "null")
                                    paramValue = DBNull.Value;

                                q.WHERE(column.ColumnName, comp, paramValue);
                            }
                        }
                    }
                    result = q.ExecuteDataSet();
                }
                else if(!String.IsNullOrEmpty(_url.SpName))
                {
                    StoredProcedure sp = new StoredProcedure(_url.SpName);

                    if(_url.Parameters != null)
                    {
                        IDictionaryEnumerator loopy = _url.Parameters.GetEnumerator();
                        while(loopy.MoveNext())
                            sp.Command.AddParameter(loopy.Key.ToString(), loopy.Value, DbType.AnsiString);
                    }
                    result = sp.GetDataSet();
                }
            }
            return result;
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:77,代码来源:RESTHandler.cs

示例6: Query_OrderBy

        public void Query_OrderBy()
        {
            Query q = new Query("Products", "Northwind");
            TableSchema.Table ts = DataService.GetTableSchema("Products", "Northwind");
            q.OrderBy = OrderBy.Desc(ts.GetColumn("ProductID"));

            DataSet ds = q.ExecuteDataSet();

            //should bring 77 as first
            Assert.IsTrue(ds.Tables[0].Rows[0]["ProductID"].Equals(77));
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:11,代码来源:QueryTest.cs

示例7: Acc_Query_OrderByCollection

        public void Acc_Query_OrderByCollection()
        {
            Query q = new Query("Products", "NorthwindAccess");
            TableSchema.Table ts = DataService.GetTableSchema("Products", "NorthwindAccess");
            q.OrderByCollection.Add(OrderBy.Desc(ts.GetColumn("CategoryID")));
            q.OrderByCollection.Add(OrderBy.Desc(ts.GetColumn("ProductID")));

            DataSet ds = q.ExecuteDataSet();

            //should bring 73 as first
            Assert.IsTrue(ds.Tables[0].Rows[0]["ProductID"].Equals(73));
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:12,代码来源:QueryTest.cs

示例8: TestJSONResultStringZeroRecords

 public void TestJSONResultStringZeroRecords()
 {
     Query q = new Query(Product.Schema).WHERE(Product.Columns.ProductID, int.MaxValue);
     DataSet ds = q.ExecuteDataSet();
     string result = handler.FormatOutput(ds);
     RESTfullContent content = handler.ConvertOutputToEndFormat(result, currentUrl);
     Assert.AreEqual("text/json", content.ContentType);
     string expectedResult = "{ \"Products\": {\"Product\": null }}";
     Assert.AreEqual(expectedResult, content.Content);
 }
开发者ID:daveneeley,项目名称:SubSonic-2.0,代码行数:10,代码来源:RESTHandlerTests.cs

示例9: TestJSONResultStringMultipleRecords

 public void TestJSONResultStringMultipleRecords()
 {
     Query q = new Query(Product.Schema).WHERE(Product.Columns.ProductID, SubSonic.Comparison.In, new int[] {1,2});
     DataSet ds = q.ExecuteDataSet();
     string result = handler.FormatOutput(ds);
     RESTfullContent content = handler.ConvertOutputToEndFormat(result, currentUrl);
     Assert.AreEqual("text/json", content.ContentType);
     string expectedResult = "{ \"Products\": {\"Product\": [ {\"AttributeXML\": \"<ArrayOfProductAttribute xmlns:xsi=\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\" xmlns:xsd=\\\\\"http://www.w3.org/2001/XMLSchema\\\\\"\\\\><ProductAttribute\\\\><AttributeName\\\\>Test1</AttributeName\\\\><AttributeValue xsi:type=\\\\\"xsd:string\\\\\"\\\\>String Value</AttributeValue\\\\><CurrencyOffset\\\\>12</CurrencyOffset\\\\></ProductAttribute\\\\><ProductAttribute\\\\><AttributeName\\\\>Test2</AttributeName\\\\><AttributeValue xsi:type=\\\\\"xsd:dateTime\\\\\"\\\\>2007-03-09T10:42:00.6517547-10:00</AttributeValue\\\\><CurrencyOffset\\\\>-100</CurrencyOffset\\\\></ProductAttribute\\\\></ArrayOfProductAttribute\\\\>\", \"CategoryID\": \"1\", \"CreatedOn\": \"2007-05-22T19:43:04-06:00\", \"DateCreated\": \"2007-05-22T19:44:42-06:00\", \"Deleted\": \"false\", \"Discontinued\": \"false\", \"ModifiedBy\": \"Unit Test\", \"ModifiedOn\": \"2007-05-24T06:31:51-06:00\", \"ProductGUID\": \"52c7760f-6b66-46e7-a99b-67cf142f2a6c\", \"ProductID\": \"1\", \"ProductName\": \"Chai\", \"QuantityPerUnit\": \"10 boxes x 20 bags\", \"ReorderLevel\": \"10\", \"SupplierID\": \"16\", \"UnitPrice\": \"50.0000\", \"UnitsInStock\": \"39\", \"UnitsOnOrder\": \"0\" }, {\"AttributeXML\": null, \"CategoryID\": \"1\", \"CreatedOn\": \"2007-05-22T19:43:04-06:00\", \"DateCreated\": \"2007-05-22T19:44:42-06:00\", \"Deleted\": \"false\", \"Discontinued\": \"false\", \"ModifiedBy\": \"Unit Test\", \"ModifiedOn\": \"2007-05-24T06:31:51-06:00\", \"ProductGUID\": \"729360ee-ec54-4e02-9973-2fb3fd2cffac\", \"ProductID\": \"2\", \"ProductName\": \"Chang\", \"QuantityPerUnit\": \"24 - 12 oz bottles\", \"ReorderLevel\": \"25\", \"SupplierID\": \"1\", \"UnitPrice\": \"50.0000\", \"UnitsInStock\": \"17\", \"UnitsOnOrder\": \"40\" } ] }}";
     Assert.AreEqual(expectedResult, content.Content);
 }
开发者ID:daveneeley,项目名称:SubSonic-2.0,代码行数:10,代码来源:RESTHandlerTests.cs


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