Type is not a valid type to map
See original GitHub issueIf the mongo db set type is an interface i.e. MongoDbSet<IMyInterfaceType>
it throws an error.
Type is not a valid type to map (Parameter 'entityType')
Is there an example of how I can set this up? Some of my collection types are concrete though have properties that are interface types.
Issue Analytics
- State:
- Created 5 months ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
'std::map' : 'SomeClass' is not a valid template type ...
I currently have a class that looks like the following . #define SET_METHOD( t , n ) \ private: t n; \ public:...
Read more >all map elements must have the same type · Issue #21384 · ...
This default value is not compatible with the variable's type constraint: element ["a"]: all map elements must have the same type.
Read more >Type Constraints - Configuration Language | Terraform
Within the Terraform language, they are only valid in the type argument ... Terraform does not provide any way to directly represent lists,...
Read more >ERROR map of any single type required : r/Terraform
The error is saying it doesn't know what type the map is, so you need to define the type. Upvote 2
Read more >Mastering TypeScript mapped types
In this post, we'll cover mapped types in TypeScript, a real-world example of them, and utility types including Partial, Readonly, and Pick.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is another case of “kinda”. If you were lookkng for a specific type, you can use
OfType<YourInheritedType>()
on your LINQ query to get it. It can have some weirdness still but you’ll be hitting more edge cases of the driver itself.This kinda deserialization control is basically what the MongoDB driver gives us. Under certain other situations, I do hijack it a bit to make it smarter (see the section in the readme about runtime type discovery) but outside of that, it is whatever the driver does.
In theory, I could try and hijack it further to use similar smartness to directly do what you’re suggesting on an entity by entity basis but that’s gonna take a lot of digging into.
Currently you can’t specify an interface on the
MongoDbSet
but you can use a shared base class if there are common properties you want across multiple types.I haven’t otherwise done a ton of testing how interfaces would behave through MongoFramework and the driver, particularly around discriminators (the
_t
property in the document).