C
C#12mo ago
Foxtrek_64

❔ fluent api naming/design

Hi all, working on designing a fluent api inspired by EF Core, in this case the IEntityTypeBuilder I am trying to determine language to describe these situations: Exactly one of (set of properties) required One or more (set of properties) required If property 1 is present, property 2 must be present If any of (set of properties), (set of properties) is required Here's some I've thought of: builder.OneOf(x => x.Foo, x => x.Bar) builder.AnyOf(x => x.Foo, x => x.Bar) Builder.Required(x => x.Property2).When(x => x.Property1, isPresent: true) I should note, if a property is always mandatory, it is a naked property in the model (public string Name { get;}) If it is optional or conditionally optional, it exists as an Optional<T>, which helps account for cases where logically null and logically missing are two different scenarios.
5 Replies
Foxtrek_64
Foxtrek_6412mo ago
Won't let me edit but it should be builder.OneOf(x => new { x.Foo, x => x.Bar})
JakenVeina
JakenVeina12mo ago
is there a question here at all?
Foxtrek_64
Foxtrek_6412mo ago
Sort of? Mostly looking for ideas for a syntax that works. I've never built anything with a fluid api
JakenVeina
JakenVeina12mo ago
you seem to be on the right track
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Github Actions on .NET SDK 8.0.100-preview.5.23303.2Hello, when I use SDK 6, everything works, but on 8 it does not. Locally it works. ''' name: .NET❔ Trying to setup C# environment for first time. Debian linuxdistro: Debian 12 I installed .net stuff using these instructions: https://learn.microsoft.com/en-us❔ Good way to make sure a user is allowed to do something based on context in ASP.NET?I'm making a website where people can join projects and then post in those projects. Currently, in oForeach loop inside List<T> classOkay so I'm actually quite confused on this. I have a collection of roles that I'd like to store ins❔ CS0103: The name 'HudController' does not exist in the current contextI am using the package SpiderHeck.GameLibs 1.25.0-r.4 from https://nuget.modweaver.org. My IDE (RideEF Error SQLite Error 1: 'no such table: __EFMigrationsHistory'. when i run dotnet ef databas updateiam using linux and vs code .Net 7 was following this tutorial https://www.youtube.com/watch?v=PDiRD❔ Linq Query HELPI have this entity. During deletion, I would like to load all related entities, so that I can delete❔ What is the question to ask for placing a class inside Core ou Infrastructure projectI sometimes hear that infrastructure project must contains only class who communicate with external ❔ Should I test my mediator class ?Hello, Should I Test my mediator class ? I ask the question because it manage interaction between d✅ Choosing the right Event in WPFI have created a notification marker that you can see on the image. It shall display how many new en