-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.8.0
-
Component/s: None
-
None
-
Environment:MongoDB version 4.0.6
.Core 2.2
-
None
-
None
-
None
-
None
-
None
-
None
-
None
[BsonDefaultValue(0m)] shows the compilation error: Error CS0182 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
However if used with an integer in an object plroperty such as:
[BsonDefaultValue(0)]
public decimal Amount { get; set; }
And then subsequently loading a record with no value for Amount from the database, the error Unable to cast object of type 'System.Int32' to type 'System.Decimal' is thrown.
So it appears that you cannot set a default of the correct type for decimal currently.