本文整理汇总了C#中Mono.Data.Sqlite.SqliteDataReader.GetOrdinal方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteDataReader.GetOrdinal方法的具体用法?C# SqliteDataReader.GetOrdinal怎么用?C# SqliteDataReader.GetOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.SqliteDataReader
的用法示例。
在下文中一共展示了SqliteDataReader.GetOrdinal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTaskCoreFromCursor
/// <summary>
/// Gets the taskcore object from the sqlite cursor
/// </summary>
/// <param name="cursor">
/// A <see cref="SqliteDataReader"/>. This won't be traversed, must be
/// called each time the cursor moves ahead
/// </param>
/// <returns>
/// A <see cref="TaskCore"/> - allocated and re-created
/// Returns null if reading failed
/// </returns>
public static TaskCore GetTaskCoreFromCursor(SqliteDataReader cursor)
{
// this assumes a single task exists
// the task to be extracted from the cursor
TaskCore task = new TaskCore ();
try {
task.Id = cursor.GetInt32 (cursor.GetOrdinal ("TaskId"));
task.Depends = cursor.GetInt32 (cursor.GetOrdinal ("Depends"));
task.Title = cursor.GetString (cursor.GetOrdinal ("Name"));
task.Description = cursor.GetString (cursor.GetOrdinal ("Description"));
task.Priority = cursor.GetInt32 (cursor.GetOrdinal ("Priority"));
task.DueDate = cursor.GetDateTime (cursor.GetOrdinal ("DueDate"));
task.CreateDate = cursor.GetDateTime (cursor.GetOrdinal ("CreateDate"));
} catch {
log.ERROR ("Reading from cursor failed");
return null;
}
// now, extract the comments.
SqliteCommand cmd = new SqliteCommand (conn);
cmd.CommandText = String.Format ("SELECT * FROM Comments WHERE (TaskId = {0});", task.Id);
log.WARN ("Trying to read comments with query - " + cmd.CommandText);
SqliteDataReader commentCursor = cmd.ExecuteReader ();
while (commentCursor.Read ()) {
CommentData comment = new CommentData ();
try {
comment.Id = commentCursor.GetInt32 (commentCursor.GetOrdinal ("CommentID"));
comment.TaskId = commentCursor.GetInt32 (commentCursor.GetOrdinal ("TaskId"));
comment.Title = commentCursor.GetString (commentCursor.GetOrdinal ("Subject"));
comment.Author = commentCursor.GetString (commentCursor.GetOrdinal ("Author"));
comment.Content = commentCursor.GetString (commentCursor.GetOrdinal ("Message"));
comment.PostDate = commentCursor.GetDateTime (commentCursor.GetOrdinal ("PostDate"));
log.DEBUG ("Extracted comment - " + comment.ToString ());
} catch {
log.ERROR ("Something went wrong while retrieving comment");
return null;
}
task.Comments.Add (comment);
}
log.DEBUG ("Extracted task as : " + task.ToString ());
return task;
}