-
-
Save bogdangrigg/9a0cea5dd80c93003e47ac316ff9b153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeedStorage | |
{ | |
public FeedStorage() | |
{ | |
GroupStoryChildIdList = ""; | |
} | |
[PrimaryKey] | |
public string Id { get; set; } | |
public DateTime FeedItemDateTime { get; set; } | |
public string ItemType { get; set; } | |
public bool IsNew { get; set; } | |
public string Json { get; set; } | |
public string GroupStoryChildIdList { get; set; } | |
} | |
private SQLiteConnection Connection | |
{ | |
get | |
{ | |
CheckDatabaseExists (); | |
//SQLite3.Config(SQLite3.ConfigOption.MultiThread); | |
return new SQLiteConnection (DatabaseFilename, true); | |
} | |
} | |
private void ExecuteBlock (SQLiteConnection conn, Action<SQLiteConnection> func) | |
{ | |
if (conn == null) | |
{ | |
using (var localConn = Connection) | |
{ | |
func (localConn); | |
} | |
} else | |
{ | |
func (conn); | |
} | |
} | |
public List<FeedItem> GetStories (SQLiteConnection conn = null) | |
{ | |
List<FeedItem> items = new List<FeedItem> (); | |
ExecuteBlock (conn, delegate(SQLiteConnection c) { | |
var feedItems = from item in c.Table<FeedStorage> () | |
where (item.ItemType != "Message") | |
orderby item.FeedItemDateTime descending select item; | |
foreach (var item in feedItems) | |
{ | |
var feedItem = JsonSerializer.DeserializeFromString<FeedItem> (item.Json); | |
items.Add (feedItem); | |
} | |
BTLogger.Log ("GetStories: {0} items", items.Count); | |
}); | |
return items; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment