Hello everyone I'm developing nuget package as a side project, with the package the user will be able to retrieve data from my MySQL database server by executing a function that contains SQL query in it let's call it `GetStuff()`.
Example of the GetStuff code:
public class GetStuff : IDisposable {
public string? name;
public void Dispose() {
}
public GetStuff() {
Console.WriteLine("Connecting to Server...");
ConnectionGetter.con.Open();
String _select = "SELECT stuff FROM information;";
ConnectionGetter.command = new MySqlCommand(_select, ConnectionGetter.con);
MySqlDataReader _read = ConnectionGetter.command.ExecuteReader();
while (_read.Read()) {
name = _read.GetString(0);
}
_read.Close();
}
Example usage:
String myUsername = "";
using(GetStuff gs = new GetStuff()) {
myUsername = gs.name;
}
ConnectionGetter class will retrieve connection string from App.Config:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace officialAPIFS {
public class ConnectionGetter {
private static string access = System.Configuration.ConfigurationManager.ConnectionStrings["CONNECTIONSETUP"].ConnectionString;
public static MySqlConnection con = new MySqlConnection(access);
public static MySqlCommand command;
}
}
And the main problem is that the SQL query is exposed when you're using intellisense and I want to avoid my table, column, or anything that's related to the SQL query from the function from getting exposed to the user, am I doing this wrong? what are the safer way to do this so the user cannot see the SQL query code behind the function?
What I have tried:
I'm completely lost and google shows irrelevant results.