polymorphism in Entity Framework (.NET Core)
Anyone has any experience they want to share? I'm currently on designing a project, and I can't really get a good feel about how to do this in a proper way.
The project use case is pretty simple, the user can create their own data fields, and assign values to them. For this, they have DataField<T> and DataValue<T>.
DataField<T> has T defaultValue
DataValue<T> has T value and a refenrece to field for metadata.
So I have a baseclass, DataField and DataValue where T : object.
Since object is not supported in SQL for obvious reasons, I have to write it into something it can understand.
Currently I am trying to create some form of converter - so when I do the modelBuilder.Property(field => field.DefaultValue).HasConversion() i could somehow parse the converter depending on the type.
But I wanted to see if anyone has solved the same problem? Worst case I could always pass it as a string back and fourth, and do some manual conversion, but I don't really like the idea.
0 comments:
Post a Comment