private string HintToSql(IHint hint, MySqlCommand command) { if (hint is TimestampRange) { var range = (TimestampRange)hint; var sb = new StringBuilder(); if (range.From.HasValue) { sb.Append(" created_at >= @TimestampFrom "); command.Parameters.AddWithValue("@TimestampFrom", range.From.Value.Ticks); } if (range.From.HasValue && range.To.HasValue) { sb.Append("AND"); } if (range.To.HasValue) { sb.Append(" created_at < @TimestampTo "); command.Parameters.AddWithValue("@TimestampTo", range.To.Value.Ticks); } return(sb.ToString()); } if (hint is PersistenceIdRange) { var range = (PersistenceIdRange)hint; var sb = new StringBuilder(" persistence_id IN ("); var i = 0; foreach (var persistenceId in range.PersistenceIds) { var paramName = "@persistence_id" + (i++); sb.Append(paramName).Append(','); command.Parameters.AddWithValue(paramName, persistenceId); } return(range.PersistenceIds.Count == 0 ? string.Empty : sb.Remove(sb.Length - 1, 1).Append(')').ToString()); } else if (hint is WithManifest) { var manifest = (WithManifest)hint; command.Parameters.AddWithValue("@manifest", manifest.Manifest); return(" manifest = @manifest"); } else { throw new NotSupportedException(string.Format("MySql journal doesn't support query with hint [{0}]", hint.GetType())); } }
protected virtual string HintToSql(IHint hint, DbCommand command) { if (hint is TimestampRange) { var range = (TimestampRange)hint; var sb = new StringBuilder(); if (range.From.HasValue) { sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" >= @TimestampFrom "); AddParameter(command, "@TimestampFrom", DbType.Int64, range.From.Value); } if (range.From.HasValue && range.To.HasValue) { sb.Append("AND"); } if (range.To.HasValue) { sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" < @TimestampTo "); AddParameter(command, "@TimestampTo", DbType.Int64, range.To.Value); } return(sb.ToString()); } if (hint is PersistenceIdRange) { var range = (PersistenceIdRange)hint; var sb = new StringBuilder(" e.").Append(Configuration.PersistenceIdColumnName).Append(" IN ("); var i = 0; foreach (var persistenceId in range.PersistenceIds) { var paramName = "@Pid" + (i++); sb.Append(paramName).Append(','); AddParameter(command, paramName, DbType.String, persistenceId); } return(range.PersistenceIds.Count == 0 ? string.Empty : sb.Remove(sb.Length - 1, 1).Append(')').ToString()); } else if (hint is WithManifest) { var manifest = (WithManifest)hint; AddParameter(command, "@Manifest", DbType.String, manifest.Manifest); return($" e.{Configuration.ManifestColumnName} = @Manifest"); } else { throw new NotSupportedException($"Sqlite journal doesn't support query with hint [{hint.GetType()}]"); } }
private string HintToSql(IHint hint, SQLiteCommand command) { if (hint is TimestampRange) { var range = (TimestampRange)hint; var sb = new StringBuilder(); if (range.From.HasValue) { sb.Append(" timestamp >= @TimestampFrom "); command.Parameters.AddWithValue("@TimestampFrom", range.From.Value); } if (range.From.HasValue && range.To.HasValue) sb.Append("AND"); if (range.To.HasValue) { sb.Append(" timestamp < @TimestampTo "); command.Parameters.AddWithValue("@TimestampTo", range.To.Value); } return sb.ToString(); } if (hint is PersistenceIdRange) { var range = (PersistenceIdRange)hint; var sb = new StringBuilder(" persistence_id IN ("); var i = 0; foreach (var persistenceId in range.PersistenceIds) { var paramName = "@Pid" + (i++); sb.Append(paramName).Append(','); command.Parameters.AddWithValue(paramName, persistenceId); } return range.PersistenceIds.Count == 0 ? string.Empty : sb.Remove(sb.Length - 1, 1).Append(')').ToString(); } else if (hint is WithManifest) { var manifest = (WithManifest)hint; command.Parameters.AddWithValue("@Manifest", manifest.Manifest); return " manifest = @Manifest"; } else throw new NotSupportedException(string.Format("Sqlite journal doesn't support query with hint [{0}]", hint.GetType())); }
protected virtual string HintToSql(IHint hint, DbCommand command) { if (hint is TimestampRange) { var range = (TimestampRange)hint; var sb = new StringBuilder(); if (range.From.HasValue) { sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" >= @TimestampFrom "); AddParameter(command, "@TimestampFrom", DbType.Int64, range.From.Value); } if (range.From.HasValue && range.To.HasValue) sb.Append("AND"); if (range.To.HasValue) { sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" < @TimestampTo "); AddParameter(command, "@TimestampTo", DbType.Int64, range.To.Value); } return sb.ToString(); } if (hint is PersistenceIdRange) { var range = (PersistenceIdRange)hint; var sb = new StringBuilder(" e.").Append(Configuration.PersistenceIdColumnName).Append(" IN ("); var i = 0; foreach (var persistenceId in range.PersistenceIds) { var paramName = "@Pid" + (i++); sb.Append(paramName).Append(','); AddParameter(command, paramName, DbType.String, persistenceId); } return range.PersistenceIds.Count == 0 ? string.Empty : sb.Remove(sb.Length - 1, 1).Append(')').ToString(); } else if (hint is WithManifest) { var manifest = (WithManifest)hint; AddParameter(command, "@Manifest", DbType.String, manifest.Manifest); return $" e.{Configuration.ManifestColumnName} = @Manifest"; } else throw new NotSupportedException($"Sqlite journal doesn't support query with hint [{hint.GetType()}]"); }