-
Notifications
You must be signed in to change notification settings - Fork 22
Primitives
A simple, plain type with no members or elements, usually mapped to a single field of a database, eg.: string, int, bool
.
The mapper copies primitives as-is without trying to recursively iterate members or items. Target values are overwritten.
The list of built-in primitives can be found here.
Notice that any type can be configured as a primitive, even if it has members or items. eg.: string
is an array of char
, but for mapping purposes, we don't want to map it char by char but just copy the entire string value.
There are other custom or 3rd party types that may need to be treated as primitives, eg.: System.Data.Spatial.DbGeography
, otherwise errors will occur as those types are not suitable to member by member mapping.
In order to mark a type as primitive, add it to the Primitives list when configuring the library:
optionsBuilder.UseMapping(cfg =>
{
cfg.Default(opts =>
{
opts.Primitives.Add(typeof(DbGeography));
});
});