StilauGamer
StilauGamer
Explore posts from servers
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
Yeah, its just that you use the same db context over the whole user request.. In Blazor, 1 scoped service last from when he starts viewing till he closes / refreshes, etc.. So in theory, when using a db context, you have it alive for the whole time, if its not disposed at some point tho ofc.. But then I don't need to do it in my web apis :sunglas: Another mystery solved for today! 🫡
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
From my understanding, the DB Context Factory is more widely used within Blazor applications where the scope is more wide... The scope is per user request and not just a HTTP request like in a Web API.. So its more recommended to manually create the db context, etc in Blazor. But in a Web API, you are good enough with just injecting the DB Context directly as its scoped to that request only.. Thats from what I understood. Reference to the article
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
I don't remember exactly where, but I read that you should use the factory part of EF, or smth
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
I was using this implementation: builder.Services.AddPooledDbContextFactory<ApplicationDbContext>(optionsBuilder => { });
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
So I should just inject the DB Context directly, and not use the IDbContextFactory part 🤓 I was confused myself, but I found it somewhere and it told me that I should use that for pooling, etc
15 replies
CC#
Created by StilauGamer on 1/21/2024 in #help
Is Inside a polygon algorithm..
I believe it has something to do with how I am sorting the vertices based on the centroid.
3 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So I should make [LoggerMessage] for each logging I do?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
ahhh, went training so didn't see the last messsages. Basically waht it does is that the source generator detects this [LoggerMessage(.........)] and then creates the code inside the method automatically. Right?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So basically like this: Log.BotStarted(_logger, _client.CurrentUser.Username);
public partial class Log
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "{Username} has been started!")]
public static partial void BotStarted(ILogger logger, string username);
}
public partial class Log
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "{Username} has been started!")]
public static partial void BotStarted(ILogger logger, string username);
}
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
🥹
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So instead of doing _logger.LogInformation("{Username} has hit an error", _client.CurrentUser.UserName), I should do this.
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
CustomEventName 🤔
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Ahh, and this is the most official and recommended way of doing logging ig?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So basically. I make a log method. Like this:
[LoggerMessage(
EventId = 20,
Level = LogLevel.Critical,
Message = "{Username} has hit an error!")]
public static partial void LogUserError(
ILogger logger, string Username);
[LoggerMessage(
EventId = 20,
Level = LogLevel.Critical,
Message = "{Username} has hit an error!")]
public static partial void LogUserError(
ILogger logger, string Username);
and when I want to use it I can do smth like: LogUserError(logger, _client.CurrentUser.UserName);
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
😂
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Okay wtf
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Ahh okay, I'll have a read on it. I've fallen really for C# and just trying to learn as much as I can lol But its not always the easiest 😅
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
And there you talk about how to do it correctly when it comes to logging?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Bro is filling my mind, I feel my brain is expanding 😂
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Ahhhhhhh
137 replies