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


C# StoredProcedure.ExecuteDataSet方法代码示例

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


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

示例1: GenerateReturnSet

        /// <summary>
        /// Data retrieval
        /// </summary>
        /// <returns></returns>
        private DataSet GenerateReturnSet()
        {
            DataSet result = null;
            if(_url != null)
            {
                SqlQuery qry = null;
                //Query q;

                if(!String.IsNullOrEmpty(_url.TableName))
                {
                    qry = new Select().From(_url.TableName);
                    IDataProvider provider = ProviderFactory.GetProvider();
                    ITable tbl = provider.FindTable(_url.TableName);

                    if(_url.PrimaryKey != null)
                        qry = qry.Where(tbl.PrimaryKey.Name).IsEqualTo(_url.PrimaryKey);
                    //q.WHERE(q.Schema.PrimaryKey.ParameterName, _url.PrimaryKey);

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

                        string paramName;
                        object paramValue;

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

                            int pageSize = 0;
                            int pageIndex = -1;

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

                                if(paramName.ToLowerInvariant() == "pageindex")
                                    pageIndex = int.Parse(paramValue.ToString());

                                if(pageSize > 0 && pageIndex > -1)
                                    qry.Paged(pageIndex + 1, pageSize);
                            }
                            else
                            {
                                Comparison comp;
                                EvalComparison(paramName, out paramName, out comp);
                                column = tbl.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, "%");
                                    qry = qry.Where(column.Name).Like(paramValue.ToString());
                                }
                                else if(paramValue.ToString().ToLower() == "null")
                                    qry = qry.Where(column.Name).IsNull();

                                //q.WHERE(column.ColumnName, comp, paramValue);
                            }
                        }
                    }

                    result = provider.ExecuteDataSet(qry.GetCommand());
                }
                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.ExecuteDataSet();
                }
            }
            return result;
        }
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:87,代码来源:RESTHandler.cs


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