本文整理汇总了C#中SelectStatement.Next方法的典型用法代码示例。如果您正苦于以下问题:C# SelectStatement.Next方法的具体用法?C# SelectStatement.Next怎么用?C# SelectStatement.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectStatement
的用法示例。
在下文中一共展示了SelectStatement.Next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// If configured, this function reads from a SQLite database caching previously known hashes.
/// The motivation for this is that the most expensive operation would be the MD5 hash calculation;
/// That means that on a second run of DetectDuplicates, we may want to reuse existing known MD5 hashes.
/// </summary>
public bool Initialize(string database_filename, Dictionary<long, Dictionary<string, string>> cache)
{
if (string.IsNullOrEmpty(database_filename))
return false;
Filename = database_filename;
try
{
// connect to database
Trace.TraceInformation("About to read cache from \"{0}\"", Filename);
Database = new Database("Data Source=" + Filename);
// make sure lookup table exists
Database.ExecuteNonQuery(@"CREATE TABLE IF NOT EXISTS hashes (hash TEXT, filename TEXT);");
DateTime cacheStartTime = DateTime.Now;
// read known hashes from lookup table
int CachedHashesRead = 0;
using (SelectStatement ss = new SelectStatement(Database, "SELECT hash, filename FROM hashes", null))
{
while (ss.Next())
{
string hash = ss.AsText(0);
string filename = ss.AsText(1);
CacheValues[filename.ToLower()] = hash;
++CachedHashesRead;
}
}
if (CachedHashesRead == 0)
{
Console.WriteLine("Cache is empty as of yet...");
}
else
{
TimeSpan elapsed = DateTime.Now - cacheStartTime;
Console.WriteLine("Read {0} hashes from the cache in {1}...", CachedHashesRead, elapsed);
}
return true;
}
catch (Exception e)
{
Tools.DumpException(e, "ReadCache() caught an exception while reading \"{0}\"", Filename);
return false;
}
}
示例2: ExecuteScalar
public object ExecuteScalar(string stmt, ParameterList pl = null)
{
using (SelectStatement ss = new SelectStatement(this, stmt, pl))
{
if (ss.Next())
{
return ss.DataReader[0];
}
}
return null;
}