❔ 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
Won't let me edit but it should be builder.OneOf(x => new { x.Foo, x => x.Bar})
is there a question here at all?
Sort of? Mostly looking for ideas for a syntax that works. I've never built anything with a fluid api
you seem to be on the right track
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.