Benutzer protokolliert. < /li>
Wenn Benutzer Benutzer is authenticated wird eine Unternehmensliste angezeigt. < /li>
Der Benutzer kann zwischen einem der Unternehmen in der Liste wählen. CompanyDBName und CompanyUi der ausgewählten Firma (der einzige Ort, an dem wir speichern, war ProtesedSessionStorage [Scoped Service], da es sich um einen Ort mit einem Lebens -Cola der Sitzung handelt, der in der Benutzeranmeldung bittet und mit dem Benutzeranmelden endet). < /ul>
Code: Select all
public class MainService
{
private readonly ProtectedSessionStorage _protectedSessionStorage;
public string DbConnectionString{ get; set; } = "Data Source=localhost\SQLEXPRESS;Initial Catalog=;Integrated Security=True";
public SessionDataService(ProtectedSessionStorage protectedSessionStorage)
{
// ***The Error Happens Here *** - in the Injection of ProtectedSessionStorage
_protectedSessionStorage = protectedSessionStorage;
}
async Task GetCompanyConnectionString()
{
// Get CompanyDbName from ProtectedSessionStorage
var companyDbName = await _protectedSessionStorage.GetAsync("UserDb");
// Add to CompanyDbName to DbConnectionString (that is common to all sessions)
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(DbConnectionString);
builder.InitialCatalog = companyDbName;
// returns ConnectionString that we use by A session in the DataBaseFactory calls
return builder.ToString();
}
}
< /code>
builder.Services.AddSingleton();