/// <summary> /// Obtiene un comando para una base de datos /// </summary> private DataProviderCommand GetProviderDataBaseCommand(string sql, Dictionary <string, object> parameters) { DataProviderCommand command = new DataProviderCommand(); // Añade el comando command.Sentences.Add("Sentence", sql); command.Parameters = parameters; // Devuelve el comando return(command); }
public static void Query(string soql, params object[] arguments) { // replace parameter names — :email with p0, :name with p1, etc. var index = 0; var soqlQuery = Regex.Replace(soql, @"(\:\S+)", m => $"p{index++}"); var command = new DataProviderCommand(soqlQuery); // prepare parameters for the data provider command for (var i = 0; i < arguments.Length; i++) { var param = new DataProviderParameter("p" + i, arguments[0]); command.Parameters.Add(param); } // execute the command and get the results command.Execute(); }