public static string SpToStringScalar(string app, string storedProcedure, MySqlParameter[] parameters) { using MySqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; foreach (MySqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } return(command.ExecuteScalar().ToString()); } public string SpToStringScalar(string storedProcedure, MySqlParameter[] parameters, string setting = "app") { using MySqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; foreach (MySqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } return(command.ExecuteScalar().ToString()); } public static int SpToIntScalar(string app, string storedProcedure, MySqlParameter parameter)
public static bool SpToBoolScalar(string app, string storedProcedure, MySqlParameter parameter) { using MySqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; return(Convert.ToBoolean(command.ExecuteScalar())); } public bool SpToBoolScalar(string storedProcedure, MySqlParameter parameter, string setting = "app") { using MySqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; return(Convert.ToBoolean(command.ExecuteScalar())); } public static bool SpToBoolScalar(string app, string storedProcedure, MySqlParameter[] parameters)
public static DataSet SpToDataSet(string app, string storedProcedure, MySqlParameter parameter) { using MySqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; MySqlDataAdapter adapter = new(command); DataSet dataS = new(); adapter.Fill(dataS, "Result"); return(dataS); } public DataSet SpToDataSet(string storedProcedure, MySqlParameter parameter, string setting = "app") { using MySqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using MySqlCommand command = new(storedProcedure, connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; MySqlDataAdapter adapter = new(command); DataSet dataS = new(); adapter.Fill(dataS, "Result"); return(dataS); } public static DataSet SpToDataSet(string app, string storedProcedure, MySqlParameter[] parameters)
public static string SpToStringScalar(string app, string storedProcedure, SqlParameter parameter) { using SqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; return(command.ExecuteScalar().ToString()); } public string SpToStringScalar(string storedProcedure, SqlParameter parameter, string setting = "app") { using SqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; command.Parameters.Add(parameter).Value = parameter.Value; return(command.ExecuteScalar().ToString()); } public static string SpToStringScalar(string app, string storedProcedure, SqlParameter[] parameters)
public static List <T> SpToList <T>(string app, string storedProcedure, SqlParameter[] parameters) { using SqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; foreach (SqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } return(BConvert.ReaderToList <T>(command.ExecuteReader())); } public List <T> SpToList <T>(string storedProcedure, SqlParameter[] parameters, string setting = "app") { using SqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; foreach (SqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } return(BConvert.ReaderToList <T>(command.ExecuteReader())); } public static string SpToStringScalar(string app, string storedProcedure, SqlParameter parameter)
public static DataSet SpToDataSet(string app, string storedProcedure, SqlParameter[] parameters) { using SqlConnection connection = new() { ConnectionString = BConnectionString.GetString(app, Dev) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; foreach (SqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } SqlDataAdapter adapter = new(command); DataSet dataS = new(); adapter.Fill(dataS, "Result"); return(dataS); } public DataSet SpToDataSet(string storedProcedure, SqlParameter[] parameters, string setting = "app") { using SqlConnection connection = new() { ConnectionString = conn.GetString(setting) }; connection.Open(); using SqlCommand command = new(storedProcedure, connection) { CommandType = System.Data.CommandType.StoredProcedure }; foreach (SqlParameter parameter in parameters) { command.Parameters.Add(parameter).Value = parameter.Value; } SqlDataAdapter adapter = new(command); DataSet dataS = new(); adapter.Fill(dataS, "Result"); return(dataS); } public static SqlParameter[] EntityToParameters <T>(T obj)
public BMySql(IConfiguration configurations) { config = configurations; conn = new BConnectionString(config); }
public BSqlServer(IConfiguration configurations) { config = configurations; conn = new BConnectionString(config); }