本文整理汇总了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;
}