本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.AddParam方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.AddParam方法的具体用法?C# SQLiteCommand.AddParam怎么用?C# SQLiteCommand.AddParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteCommand
的用法示例。
在下文中一共展示了SQLiteCommand.AddParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllEventsSinceVersion
public IEnumerable<SourcedEvent> GetAllEventsSinceVersion(Guid id, long version)
{
var res = new List<SourcedEvent>();
using (var conn = new SQLiteConnection(_connectionString))
using (var cmd = new SQLiteCommand(Query.SelectAllEventsQuery, conn))
{
cmd.AddParam("EventSourceId", id).AddParam("EventSourceVersion", version);
conn.Open();
using (var reader = cmd.ExecuteReader())
{
var formatter = new BinaryFormatter();
while (reader.Read())
{
var rawData = (Byte[])reader["Data"];
using (var dataStream = new MemoryStream(rawData))
{
var bag = (PropertyBag) formatter.Deserialize(dataStream);
var evnt = (SourcedEvent)_converter.Convert(bag);
res.Add(evnt);
}
}
}
}
return res;
}
示例2: ReadFrom
public CommittedEventStream ReadFrom(Guid id, long minVersion, long maxVersion)
{
var results = new List<CommittedEvent>();
_context.WithConnection(connection =>
{
using (var cmd = new SQLiteCommand(Query.SelectAllEventsFromQuery, connection))
{
cmd.AddParam("EventSourceId", id)
.AddParam("EventSourceMinVersion", minVersion)
.AddParam("EventSourceMaxVersion", maxVersion);
results.AddRange(ReadEvents(cmd, id));
}
});
return new CommittedEventStream(id, results);
}