4 ms·
In theory, those two types shouldn’t be ints, but rather separate int wrapping types TenantId and UserId so that they can’t be mixed up at all
by bobbylarrybobby 5y ago
In theory, those two types shouldn’t be ints, but rather separate int wrapping types TenantId and UserId so that they can’t be mixed up at all
- DaiPlusPlus 5y agoUnfortunately hardly any ORMs support that (especially not EF, argh), and writing custom value-types is a painful experience given C# (still) doesn't support strict typedefs nor mixins.
- kevinmgranger 5y agoIf only structs were inheritable, then you could roll your own `struct Wrapper<T>` with operators for implicit conversion, equality, etc, and then extend it with just the name and type. Wouldn't help with the EF pain point though, and I'm sure it might confuse newcomers initially.
- DaiPlusPlus 5y agoInheritance shouldn't be abused to make-up for the lack of true mixins, though.