Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement