/// <summary> /// Initializes a new instance of the <see cref="DataQuery"/> class. /// </summary> /// <param name="database">The database</param> /// <param name="sqlString">The sql string</param> public DataQuery(Database database, string sqlString) : this(database) { this.sqlString = sqlString; }
/// <summary> /// Returns a DataQuery instance which is requested by the query key /// </summary> /// <param name="database">Database</param> /// <param name="queryKey">Query key</param> /// <param name="replacements">Replacements</param> /// <returns>DataQuery instance</returns> public virtual DataQuery GetQuery(Database database, string queryKey, Dictionary<string, string> replacements = null) { if (this.OnQueryGet != null) { this.OnQueryGet(this, EventArgs.Empty); } DatabaseManagerQuery query = this.Queries[queryKey]; DataQuery dataQuery = database.NewQuery() .SetSqlString(query.SqlCommand) .AddPlaceholders(this.QueryPlaceholders); if (replacements != null) { dataQuery.AddPlaceholders(replacements); } return dataQuery; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="DataQuery"/> class. /// </summary> /// <param name="database">The database</param> public DataQuery(Database database) { this.database = database; this.fields = new List<string>(); this.placeholders = new Dictionary<string, string>(); this.parameters = new List<DbParameter>(); }