Hello,
I am having issues with writing to the database. My class properties which are all ‘FieldValue’ custom classes. The class has 3 properties (get; private set; ) and a constructor to set the values of each property. The error looks like;
System.AggregateException: ‘One or more errors occurred. (Invalid lambda expression)’
.
.
.
BsonSerializationException: Invalid lambda expression
…
This is the first time working with Mongo DB, I hope that I am using the map correctly. Below is an example of the map and classes…
BsonClassMap.RegisterClassMap< MyClass > (cm =>
{
cm.MapProperty(m => new FieldValue< int >(m.AuthorOid.Value, m.AuthorOid.UpdatedBy, m.AuthorOid.UpdatedOn));
cm.MapProperty(m => new FieldValue< string >(m.Name.Value, m.Name.UpdatedBy, m.Name.UpdatedOn));
cm.MapProperty(m => new FieldValue< DateTime >(m.EntryDate.Value, m.EntryDate.UpdatedBy, m.EntryDate.UpdatedOn));
public class MyClass
{
public FieldValue< int > AuthorOid {get; set;}
public FieldValue< string > Name{get; set;}
public FieldValue< DateTime > EntryDate{get; set;}
}
public class FieldValue< T >
{
public FieldValue(T value, string updatedBy, DateTime? updatedOn = null)
{
Value=value;
UpdatedOn=updatedOn;
UpdatedBy = updatedBy;
}
public string UpdatedBy { get; private protected set; }
public DateTime UpdatedOn { get; private protected set; }
public T Value { get; private protected set; }
}
Thank-you for any help you can provide.