Serialize Intellenum enums

Edit page Last modified: 12 September 2024

Vogen integrates with other systems and technologies.

The generated Value Objects can be converted to and from JSON.

They can be used in Dapper, LinqToDB, and EF Core.

And it generates TypeConverter code, so that Value Objects can be used in things like ASP.NET Core MVC routes.

Integration is handled by the conversions parameter in the ValueObject attribute. The current choices are:

The default, as specified above in the Defaults property, is TypeConverter and SystemTextJson.

Other converters/serializers are:

  • Newtonsoft.Json (NSJ)

  • ServiceStack.Text

  • Dapper

  • EFCore

  • LINQ to DB

  • protobuf-net (see the FAQ section below)

They are controlled by the Conversions enum. The following has serializers for NSJ and STJ:

If you don't want any conversions, then specify Conversions.None.

If you want your own conversion, then again specify none, and implement them yourself, just like any other type. But be aware that even serializers will get the same compilation errors for new and default when trying to create VOs.

If you want to use Dapper, remember to register it—something like this:

See the examples folder for more information.