public IEnumerable <IMessageItem> getMessages(string ChatName) { using (var sqlite_command = sqlite_connection.CreateCommand()) { sqlite_command.CommandText = "SELECT * FROM messages WHERE key_remote_jid = '" + ChatName + "'"; SQLiteDataReader sqlite_datareader = sqlite_command.ExecuteReader(); Messages = new List <AndroidMessageItem>(); while (sqlite_datareader.Read()) { var item = new AndroidMessageItem(); item._id = int.Parse(sqlite_datareader["_id"] + ""); item.key_remote_jid = sqlite_datareader["key_remote_jid"] + ""; //item.key_from_me = int.Parse(sqlite_datareader["key_from_me"] + ""); //item.key_id = sqlite_datareader["key_id"] + ""; item.status = int.Parse(sqlite_datareader["status"] + ""); //item.needs_push = int.Parse(sqlite_datareader["needs_push"] + ""); item.data = sqlite_datareader["data"] + ""; item.timestamp = long.Parse(sqlite_datareader["timestamp"] + ""); item.media_url = sqlite_datareader["media_url"] + ""; //item.media_mime_type = sqlite_datareader["media_mime_type"] + ""; //item.media_wa_type = sqlite_datareader["media_wa_type"] + ""; //item.media_size = int.Parse(sqlite_datareader["media_size"] + ""); //item.media_name = sqlite_datareader["media_name"] + ""; //item.media_hash = sqlite_datareader["media_hash"] + ""; //item.latitude = double.Parse(sqlite_datareader["latitude"] + ""); //item.longitude = double.Parse(sqlite_datareader["longitude"] + ""); //item.thumb_image = sqlite_datareader["thumb_image"] + ""; item.remote_resource = sqlite_datareader["remote_resource"] + ""; //item.received_timestamp = long.Parse(sqlite_datareader["received_timestamp"] + ""); //item.send_timestamp = long.Parse(sqlite_datareader["send_timestamp"] + ""); //item.receipt_server_timestamp = long.Parse(sqlite_datareader["receipt_server_timestamp"] + ""); //item.receipt_device_timestamp = long.Parse(sqlite_datareader["receipt_device_timestamp"] + ""); //item.raw_data = sqlite_datareader["raw_data"] as byte[]; //item.recipient_count = int.Parse("0" + sqlite_datareader["recipient_count"]); //item.media_duration = int.Parse("0" + sqlite_datareader["media_duration"] + ""); //item.origin = int.Parse("0" + sqlite_datareader["origin"] + ""); Messages.Add(item); } return(Messages.OrderBy(o => o.timestamp).ToList()); } }