I wonder how I console.writeline data stored in my litedb database file. This is my POCO Class
[BsonId]
public int Id { get; set; }
public DateTime Updated { get; set; }
public DateTime Last { get; set; }
public override string ToString()
{
return string.Format("Id : {0}, Updated : {1}, Last Message : {2}",
Id,
Updated,
Last);
}
There i insert infomation in db:
using (var db = new LiteDatabase(_dbLocation))
{
var hist = db.GetCollection<MailBoxInfo>("History");
var mail = new MailBoxInfo
{
Updated = DateTime.Now,
Last = datemsg
};
hist.Insert(mail);
hist.EnsureIndex("Updated");
}
And, finally, try to output it:
using (var db = new LiteDatabase(_dbLocation))
{
var hist = db.GetCollection<MailBoxInfo>("History");
var res = hist.FindById(3);
}
Then I get exception
"Additional information: Failed to create instance for type 'TanganTask.MailBoxInfo'. Checks if has a public constructor with no parameters".
Where am I mistaken and how to solve this problem?