Skip to main content

All Questions

Tagged with
0 votes
1 answer
31 views

Best way to call handlers with almost same signature

public class Config { static Dictionary<int, IHandler handler> dictionary = new Dictionary<int, IHandler>() { { 0, new Handler() }, { 1, new Handler() }, { 2, ...
MaybeRainQ's user avatar
0 votes
0 answers
42 views

Entity Framework - Explicit column ordering with object inheritance

I have a BaseEntity class which includes common fields for all entities where I have specified the column order: public class BaseEntity { [Column(Order = 0)] public Guid Id { get; set; } ...
dbm's user avatar
  • 59
1 vote
1 answer
119 views

Choosing Between Dependency Injection and Inheritance for Accessing Constants

I have multiple classes that need access to the same set of constants. Currently, I have defined these constants in a separate class like so: public class ConfigurationConstants { public const ...
Adoulou's user avatar
  • 35
0 votes
1 answer
49 views

Dependency Injection with Generic Interface and Inheritance

I recently thought about a case where i can build the abstractions of news importer into the .NET DI Contianer. This is my example Case. This class represents a news source. public abstract class ...
LucaToni04's user avatar
0 votes
0 answers
32 views

Generic "Create" method in .NET Core that creates two entities

I have two .NET Core entities; UserAccount and Customer that has UserAccountId as foreign key. I want to have a one generic method that first creates UserAccount. Then I take UserAccountId from it and ...
amerr-k's user avatar
  • 59
-1 votes
1 answer
59 views

Dotnet class method with generic return type and one generic argument [duplicate]

I try to make a class method when return type is generic and also one of the arguments is generic. The Return type should be generic class Result, which looks like this: public class Result<T> { ...
julianuslemurrex's user avatar
1 vote
1 answer
90 views

Using dependency injection in .NET 7.0 API controller project with inheritance and explicit call to base class

This is for a learning project. How can I inject an IHttpContextAccessor or any class into the base service class without injecting it into the derived classes when the derived classes make a call to ...
dergeophysiker's user avatar
1 vote
0 answers
378 views

.NET MAUI Binding not working with control (ContentView) inheritance

I am trying to write a simple ContentView XAML control in .NET MAUI using inheritance and Binding. The control simply displays a name/value pair on a HorizontalStack - the base control displays the ...
adiaz's user avatar
  • 13
2 votes
2 answers
82 views

.NET documentation confusion around inheritance

I am reading the .NET documentation, and encountered the IdentityReference class, which states: Represents an identity and is the base class for the NTAccount and SecurityIdentifier classes. This ...
E. Johnson's user avatar
1 vote
1 answer
362 views

Unexplainable error: Record member must be a readable instance property or field of type 'T[]' to match positional parameter

I'm trying to wrap several arrays of Dto's in a wrapper, like this: public sealed record SomeWrapper<T>(T[]? L1, T[]? L2, T[]? L3) : SomeWrapper(L1, L2, L3) where T : Dto; public record ...
Zenith's user avatar
  • 177
1 vote
1 answer
57 views

Problem with generic base class and not-generic child class in an interface

I'm having some trouble with implementing an interface on a "non-generic" child class, that derives from a generic base class: public class Parent<T> where T : struct, Enum { ...
fumpel's user avatar
  • 21
0 votes
1 answer
45 views

Enforce return type of function to be the inherited generic class and not the base non-generic one

I have a base class Outcome which is inherited by a generic class Outcome(Of T). Both classes here have their own use cases, so sometimes you would want to use a non-generic Outcome and other times ...
Burhan's user avatar
  • 790
0 votes
1 answer
52 views

Set a generic class reference to a base class, where the generic class's generic parameter extends that base class

I have a class AIBrain, and two other classes "StaffBrain" and "ClientBrain". The "StaffBrain" and "ClientBrain" classes both extend the "AIBrain" ...
Radu's user avatar
  • 606
0 votes
0 answers
41 views

Additional column TempId3 is cretated on migration in Entity Framework 6

I have public abstract class DocumentBaseModel { public int Id { get; set; } } public class SaleCompileDocument : DocumentBaseModel { public ICollection<EmailNotification> ...
dm k's user avatar
  • 131
0 votes
0 answers
39 views

How to call the constructor of a derived class without calling the constructor of the base class [duplicate]

I was refreshing my limited knowledge of inheritance in c# 11 because I need it for a project. However I got unexpected results when calling the constructor of an inherited class. Any call to the ...
DogPerson's user avatar

15 30 50 per page
1
2 3 4 5
63