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


C# StoredProcedure.GetDataSet方法代码示例

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


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

示例1: TestExistingClosedConnection

        public void TestExistingClosedConnection()
        {
            using (DbConnection connection = GetConnection())
            {
                const int startId = 2;
                const int endId = 3;

                Assert.AreEqual(ConnectionState.Closed, connection.State, "The connection should be closed");

                StoredProcedure sp = new StoredProcedure("GetNames", "default");
                sp.Command.AddParameter("@StartId", startId, DbType.Int32, 4);
                sp.Command.AddParameter("@EndId", endId, DbType.Int32, 4);
                DataSet ds = sp.GetDataSet(connection);

                Assert.AreEqual(ConnectionState.Closed, connection.State, "The connection should stay closed");

                DataTable table = ds.Tables[0];
                Assert.AreEqual(endId - startId + 1, table.Rows.Count, "The table does not contain the correct number of rows");
            }
        }
开发者ID:jeremysimmons,项目名称:sixpack-library,代码行数:20,代码来源:StoredProcedureTests.cs

示例2: SP_DSTest

        public void SP_DSTest()
        {
            StoredProcedure sp = new StoredProcedure("CustOrderHist", DataService.GetInstance("Northwind"));
            sp.Command.AddParameter("@CustomerID", "ALFKI", DbType.AnsiString);
            DataSet ds = sp.GetDataSet();

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0);
        }
开发者ID:khurram063,项目名称:SubSonic-2.0,代码行数:8,代码来源:SPs.cs

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

示例4: TestGetDataSet

        public void TestGetDataSet()
        {
            const int startId = 2;
            const int endId = 3;

            StoredProcedure sp = new StoredProcedure("GetNames", "default");
            sp.Command.AddParameter("@StartId", startId, DbType.Int32, 4);
            sp.Command.AddParameter("@EndId", endId, DbType.Int32, 4);
            DataSet ds = sp.GetDataSet();

            DataTable table = ds.Tables[0];
            Assert.AreEqual(endId - startId + 1, table.Rows.Count, "The table does not contain the correct number of rows");
            for (int i = 0; i < table.Rows.Count; ++i)
            {
                Assert.AreEqual(i + startId, table.Rows[i][0], "The row is incorrect");
                Assert.AreEqual(string.Format("name{0}", i + startId), table.Rows[i][1], "The row is incorrect");
            }
        }
开发者ID:jeremysimmons,项目名称:sixpack-library,代码行数:18,代码来源:StoredProcedureTests.cs


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