Click here to Skip to main content
15,881,618 members
Home / Discussions / C#
   

C#

 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
trønderen24-Dec-22 23:13
trønderen24-Dec-22 23:13 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
BillWoodruff25-Dec-22 4:15
professionalBillWoodruff25-Dec-22 4:15 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
Sakhalean25-Dec-22 4:50
Sakhalean25-Dec-22 4:50 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
BillWoodruff25-Dec-22 5:13
professionalBillWoodruff25-Dec-22 5:13 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
trønderen25-Dec-22 11:17
trønderen25-Dec-22 11:17 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
Sakhalean25-Dec-22 14:06
Sakhalean25-Dec-22 14:06 
QuestionEF Core 6 Repository Pattern Pin
Kevin Marois23-Dec-22 9:11
professionalKevin Marois23-Dec-22 9:11 
AnswerRe: EF Core 6 Repository Pattern Pin
Richard Deeming5-Jan-23 0:02
mveRichard Deeming5-Jan-23 0:02 
Are you using Dependency Injection? Ideally, the DbContext and repository classes should be registered as "scoped" dependencies. The context would be injected into the repository, and the repository would be injected into the controller.

The connection string would usually be read from the web.config / appSettings.json file by convention:
Connection strings and models - EF6 | Microsoft Learn[^]

If you need to manage the connection string differently, then you should be able to add it to the DI registration. For example, using the Microsoft DI framework:
C#
services.AddScoped<DbContext>(_ =>
{
    string connString = Properties.Settings.Default.ConnectionString;
    return new SqlDataContext(connString);
});




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: EF Core 6 Repository Pattern Pin
Kevin Marois5-Jan-23 6:46
professionalKevin Marois5-Jan-23 6:46 
GeneralRe: EF Core 6 Repository Pattern Pin
Richard Deeming5-Jan-23 22:41
mveRichard Deeming5-Jan-23 22:41 
GeneralRe: EF Core 6 Repository Pattern Pin
Kevin Marois6-Jan-23 5:38
professionalKevin Marois6-Jan-23 5:38 
GeneralRe: EF Core 6 Repository Pattern Pin
Richard Deeming8-Jan-23 21:35
mveRichard Deeming8-Jan-23 21:35 
QuestionMysql database freezes with Visual Sudio C# Pin
Member 1405587918-Dec-22 5:44
Member 1405587918-Dec-22 5:44 
AnswerRe: Mysql database freezes with Visual Sudio C# Pin
RedDk18-Dec-22 10:10
RedDk18-Dec-22 10:10 
AnswerRe: Mysql database freezes with Visual Sudio C# Pin
Dave Kreskowiak18-Dec-22 11:20
mveDave Kreskowiak18-Dec-22 11:20 
AnswerRe: Mysql database freezes with Visual Sudio C# Pin
Richard Deeming18-Dec-22 21:08
mveRichard Deeming18-Dec-22 21:08 
QuestionMulti-threaded debugging Pin
Richard Andrew x6411-Dec-22 6:12
professionalRichard Andrew x6411-Dec-22 6:12 
AnswerRe: Multi-threaded debugging Pin
Gerry Schmitz11-Dec-22 7:09
mveGerry Schmitz11-Dec-22 7:09 
GeneralRe: Multi-threaded debugging Pin
Richard Andrew x6411-Dec-22 7:48
professionalRichard Andrew x6411-Dec-22 7:48 
GeneralRe: Multi-threaded debugging Pin
Gerry Schmitz11-Dec-22 14:50
mveGerry Schmitz11-Dec-22 14:50 
AnswerRe: Multi-threaded debugging Pin
Randor 11-Dec-22 8:46
professional Randor 11-Dec-22 8:46 
GeneralRe: Multi-threaded debugging Pin
Richard Andrew x6411-Dec-22 14:36
professionalRichard Andrew x6411-Dec-22 14:36 
PraiseRe: Multi-threaded debugging Pin
Randor 11-Dec-22 15:50
professional Randor 11-Dec-22 15:50 
QuestionRegarding a line in code Pin
vineeth s5-Dec-22 7:06
vineeth s5-Dec-22 7:06 
AnswerRe: Regarding a line in code Pin
Richard MacCutchan5-Dec-22 8:02
mveRichard MacCutchan5-Dec-22 8:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.