public AppUpdateQuery RetrieveByApp(AppUpdateQuery query) { List<IMongoQuery> mongoQueries = new List<IMongoQuery>(); mongoQueries.Add(Query.EQ("app", query.App)); mongoQueries.Add(Query.LTE("time", query.LatestTime)); if (query.EarliestTime.HasValue) { mongoQueries.Add(Query.GTE("time", query.EarliestTime)); } AppUpdate[] result = appUpdates.Find(Query.And(mongoQueries.ToArray())).ToArray(); query.Fill(result); return query; }
public AppUpdateQuery RetrieveByApp(AppUpdateQuery query) { MySqlCommand command = connection.CreateCommand(); command.CommandText = "select * from AppUpdate where App = ?App and Time <= ?LatestTime"; command.Parameters.AddWithValue("?App", query.App); command.Parameters.AddWithValue("?LatestTime", query.LatestTime); if (query.EarliestTime.HasValue) { command.CommandText += " and Time >= ?EarliestTime"; command.Parameters.AddWithValue("?EarliestTime", query.EarliestTime); } command.CommandText += ";"; List<AppUpdate> result = new List<AppUpdate>(); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { AppUpdate update = reader.ToAppUpdate(); result.Add(update); } } query.Fill(result); return query; }