You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are Primary Constructors, introduced in C# 12, supported when writing Handlers?
I have tried using them and am getting some odd behavior whereby my dependency injections e.g. _dbContext show as null in Visual Studio yet appear to exist despite that (method calls don't thrown NullReferenceException).
public class CreateThingy_CommandHandler(ApplicationDbContext _dbContext) : IRequestHandler<CreateThingyCommand, ThingyDto>
{
public async Task<ThingyDto> Handle(CreateThingyCommand cmd, CancellationToken cancellationToken)
{
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Are Primary Constructors, introduced in C# 12, supported when writing Handlers?
I have tried using them and am getting some odd behavior whereby my dependency injections e.g. _dbContext show as null in Visual Studio yet appear to exist despite that (method calls don't thrown NullReferenceException).
Beta Was this translation helpful? Give feedback.
All reactions