blazor application to connect to database code example

Example: blazor application to connect to database

public class DataAccessService
{
    private   IConfiguration config;
    public  DataAccessService(IConfiguration configuration)
    {
        config = configuration;
    }

    private  string ConnectionString
    {
        get
        {
    string _server = config.GetValue<string>("DbConfig:ServerName");
    string _database = config.GetValue<string>("DbConfig:DatabaseName");
    string _username = config.GetValue<string>("DbConfig:UserName");
    string _password = config.GetValue<string>("DbConfig:Password");

    return ($"Server={_server};Database={_database};User ID={_username};Password={_password};Trusted_Connection=False;MultipleActiveResultSets=true;");
        }
    }
  }

Tags:

Misc Example