You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
After upgrading from version 5.0.17 the constructor tagged with the BsonCtor Attribute is not called. On version 5.0.17 it worked correctly.
Code to Reproduce
public abstract class DB_Object {
[Browsable(false)]
public abstract Guid Id { get; }
public abstract string Name { get; }
[Browsable(false)]
[BsonIgnore]
public virtual Bitmap Icon => null;
public override bool Equals(object? obj) {
var other = obj as DB_Object;
if (other == null) return false;
return Id.Equals(other.Id);
}
}
public class PlayList : DB_Object {
public PlayList(string name) {
PlayListId = Guid.NewGuid();
Name = name;
}
[BsonCtor]
public PlayList(Guid _id, string name) {
PlayListId = _id;
Name = name;
}
[Browsable(false)]
public Guid PlayListId { get; }
/// <summary>
/// Playlist name.
/// </summary>
public override string Name { get; } = "";
public string Comment { get; set; } = "";
/// <summary>
/// List of image ids referenced.
/// </summary>
public List<Guid> ImageIds { get; set; } = new List<Guid>();
/// <summary>
/// Image filenames.
/// </summary>
public override Guid Id => PlayListId;
}
Expected behavior
The PlayList(Guid _id, string name) ctor should be called by LiteDB when executing the following:
var col = DB.GetPlayListCollection(DB.DataBase);
var all = col.FindAll();
foreach (var pl in all) {
if (col.FindById(pl.Id) == null) { // Returns null since the ctor is not called to initialize the id field
return;
}
}
Screenshots/Stacktrace
Additional context
The text was updated successfully, but these errors were encountered:
Version
5.0.21
Describe the bug
After upgrading from version 5.0.17 the constructor tagged with the BsonCtor Attribute is not called. On version 5.0.17 it worked correctly.
Code to Reproduce
Expected behavior
The PlayList(Guid _id, string name) ctor should be called by LiteDB when executing the following:
Screenshots/Stacktrace
Additional context
The text was updated successfully, but these errors were encountered: