< Back

Register-MdbcClassMap

Sat Jan 18, 2020 11:32 am

NAME Register-MdbcClassMap



SYNOPSIS

Registers serialized types.





SYNTAX

Register-MdbcClassMap [-Type] <Type> [-Discriminator <String>] [-ExtraElementsProperty <String>] [-IdProperty

<String>] [-Init <ScriptBlock>] [-DiscriminatorIsRequired] [-IgnoreExtraElements] [<CommonParameters>]



Register-MdbcClassMap [-Type] <Type> -Force [<CommonParameters>]





DESCRIPTION

The cmdlet registers the specified type and makes it serialized by the driver. It should be called for each

serialized type before the first serialization. Types cannot be unregistered, they are supposed to be either

serialized or converted for the entire session.



If a type is already registered by the driver, for example in another assembly, the command fails unless it is

called with just Type and Force parameters. The registered class map cannot be altered by other parameters.





PARAMETERS

-Type

Specifies the type to be treated as serialized. Use other parameters in order to tweak some serialization

options in here instead of using Bson* attributes or in addition.



Required? true

Position? 0

Default value

Accept pipeline input?

Accept wildcard characters?



-Discriminator

Specifies the type discriminator saved as the field _t. By default, the type name is used as the discriminator.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-DiscriminatorIsRequired

Tells to save the type discriminator _t. This may be useful for base classes of mixed top level documents.

Derived classes inherit this attribute and save their discriminators.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-ExtraElementsProperty

Specifies the property which holds elements that do not match other properties. Supported types:

[Mdbc.Dictionary], [BsonDocument], [Dictionary[string, object]].



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Force

Tells that the type might be already registered by the driver and this is expected. The command registers the

existing or auto created map. Parameters other than Type are not allowed.



Required? true

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-IdProperty

Specifies the property mapped to the document field _id.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-IgnoreExtraElements

Tells to ignore document elements that do not match the properties.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Init

Specifies the script which initializes the new class map defined by $_. Other parameters are applied to the

map after calling the script. Usually, the script calls `$_.AutoMap()` first.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS





RELATED LINKS