本文整理汇总了C#中SqlWriter.SelectPageSql方法的典型用法代码示例。如果您正苦于以下问题:C# SqlWriter.SelectPageSql方法的具体用法?C# SqlWriter.SelectPageSql怎么用?C# SqlWriter.SelectPageSql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlWriter
的用法示例。
在下文中一共展示了SqlWriter.SelectPageSql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public DataTable Read()
{
var sqlType = FindSqlType();
var originSql = new SqlWriter(_databaseTable, sqlType);
var selectAll = originSql.SelectPageSql();
var dt = new DataTable(_databaseTable.Name) { Locale = CultureInfo.InvariantCulture };
var dbFactory = DbProviderFactories.GetFactory(_providerName);
using (var con = dbFactory.CreateConnection())
{
con.ConnectionString = _connectionString;
using (var cmd = con.CreateCommand())
{
cmd.CommandText = selectAll;
var p = cmd.CreateParameter();
var parameterName = "currentPage";
if (sqlType == SqlType.SqlServerCe) parameterName = "offset";
p.ParameterName = parameterName;
p.Value = 1;
if (sqlType == SqlType.SqlServerCe) p.Value = 0;
cmd.Parameters.Add(p);
var ps = cmd.CreateParameter();
ps.ParameterName = "pageSize";
ps.Value = _pageSize;
cmd.Parameters.Add(ps);
using (var da = dbFactory.CreateDataAdapter())
{
da.SelectCommand = cmd;
da.Fill(dt);
}
}
}
return dt;
}