本文整理汇总了C#中ServiceStack.OrmLite.OrmLiteConnectionFactory.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.CreateCommand方法的具体用法?C# OrmLiteConnectionFactory.CreateCommand怎么用?C# OrmLiteConnectionFactory.CreateCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.OrmLite.OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.CreateCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFirstAndLastEpoch
public void GetFirstAndLastEpoch()
{
using (var db = new OrmLiteConnectionFactory(GetSQLiteConnectionString(), SqliteDialect.Provider).OpenDbConnection())
{
using (var cmd = db.CreateCommand())
{
cmd.CommandText = "SELECT dataTimestamp FROM data ORDER BY dataTimestamp limit 1";
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
long firstEpoch = (long) rdr[0];
FirstEpoch = new DateTime(firstEpoch);
}
}
cmd.CommandText = string.Format("SELECT dataTimestamp FROM data WHERE dataTimeStamp > {0} ORDER BY dataTimestamp limit 1", FirstEpoch.Ticks);
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
var secondEpoch = new DateTime((long)rdr[0]);
EpochLengthInSeconds = (int) secondEpoch.Subtract(FirstEpoch).TotalSeconds;
}
}
cmd.CommandText = "SELECT dataTimestamp FROM data ORDER BY dataTimestamp DESC limit 1";
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
long lastEpoch = (long) rdr[0];
LastEpoch = new DateTime(lastEpoch);
}
}
EpochCount = db.Scalar<long>(db.From<AgdTableTimestampAxis1>().Select(Sql.Count("*")));
}
}
}