C#C
C#3w ago
hutonahill

✅ EFCore type conversion.

https://gist.github.com/hutonahill/96ef2bea79847f5059ee13456833b0cc

I am working on a libray that runs a game. I've got a type Card. it stores a card. I want EFCore to know how to store a card. so i wrote CardToStringConverter (see the gist)

I want EFCore to use this whenever it sees Card.

I am writing a method that will add this converter (and any other i build) to properties that store a Card (other the other types i convert), AddConverters (see the gist)


The issue is collections. If i am storing a List<Card> this method wont work. Chat suggests this is not possible, but it can be kind of stupid for use cases like this, so i thought i would ask some real people with real experience.

i suspect i will have to create a CardStorage class that just stores a the string as an identifier, but i am trying to avoid that.
Gist
Converter Code. GitHub Gist: instantly share code, notes, and snippets.
Was this page helpful?