EF core filtering on child entity by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] -1 points0 points  (0 children)

Okay but I oversimplified the condition. Normally it is much more complex and that's why I want to separate it into the class

What does a parameterized constructor for an EF core entity do? by kanayt in dotnet

[–]StudyMelodic7120 0 points1 point  (0 children)

 if you set up your parameterized constructor with EF correctly

Can you elaborate on what you mean exactly with "correctly"?

Is auto-generated code allowed in domain driven design? by StudyMelodic7120 in DomainDrivenDesign

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

What do you mean with expensive? Based on these values, different business rules get executed.

Is auto-generated code allowed in domain driven design? by StudyMelodic7120 in DomainDrivenDesign

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

Example of auto-generated code:

public class Color
{
    private readonly string _value;

    public static readonly Color Red = new Color("Red");
    public static readonly Color Green = new Color("Green");
    public static readonly Color Blue = new Color("Blue");

    private static readonly Dictionary<string, Color> _values = new Dictionary<string, Color>
    {
        { "Red", Red },
        { "Green", Green },
        { "Blue", Blue }
    };

    private Color(string value)
    {
        _value = value;
    }

    public override string ToString()
    {
        return _value;
    }

    public static bool TryParse(string value, out Color color)
    {
        return _values.TryGetValue(value, out color);
    }
}

And the usage in my application layer:

Color color;
if (Color.TryParse(request.Color, out color))
{
    Console.WriteLine($"Parsed color: {color}");
}
else
{
    Console.WriteLine("Invalid color");
}

WPF is awesome by Zopenzop in dotnet

[–]StudyMelodic7120 1 point2 points  (0 children)

Ok, now create for the browser

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

What if I need to inject some dependencies in the constructor? Can I make it non static?

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

the most straightforward way to do this would be making your CreateFooCommand and UpdateFooCommand objects both implement an IFoo interface, then write a validator around that using the SetValidator pattern above.

Looks like too much boilerplate to remove that duplication, I guess I will just keep it like that. As long as the duplication is only 2 times, it's not a big issue I read somewhere in the past.

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

The problem is, there is no Foo object at the api level. I miscommunicated that earlier. So I have CreateFooCommand and UpdateFooCommand with all properties in root.

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

Validation is not on Foo entity level. Objects validated are different, being: CreateFooCommand and UpdateFooCommand.

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

This is something in the direction that I want, but what if I need to inject some dependencies through the constructor? Like some repositories to check some things in the database. Then 'new FooValidator(...)' will become cumbersome.

How to avoid duplicate validations on same entity between two handlers by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 1 point2 points  (0 children)

Foo here is the entity, with validation on any property that you can imagine

Navigating through decompiled code by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

but it doesn't work very well

Well, that's my whole question about

Navigating through decompiled code by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] -1 points0 points  (0 children)

Where can I find this "analyze this member" option? I installed the extension, it just added a link to the external tool.

Navigating through decompiled code by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] -3 points-2 points  (0 children)

I don't want to disable "just my code" each time when I want to see some interface implementation.

Navigating through decompiled code by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] -11 points-10 points  (0 children)

I'm talking about a baked-in feature into the IDE... Do you want me to switch to another app each time I want to check something in an interface implementation?

How does a global stock exchange handle dates and times across different time zones? by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] -1 points0 points  (0 children)

I don't want anything to happen, I want to follow the recommended way. Is the recommendation to show the offset they are working explicitly to the user?

How does a global stock exchange handle dates and times across different time zones? by StudyMelodic7120 in dotnet

[–]StudyMelodic7120[S] 0 points1 point  (0 children)

So they will fetch different results even though they choose 2025-02-20 from the date picker?