I have created a project using .Net Core, Blazor, and LiteDB.
There are a few articles out there which reference using LiteDB with core so I don't think there is an issue there.
Here is my code.
<p>@groups.Count()</p>
@functions{
//Collections
IEnumerable<Group> groups;
protected override void OnInit()
{
string connectionString = "Path to my .db file";
using (LiteDatabase db = new LiteDatabase(connectionString))
{
groups = db.GetCollection<Group>("Groups").FindAll();
}
}
public class Group
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool Active { get; set; }
public int XIndex { get; set; }
public int YIndex { get; set; }
public DateTime CreateDate { get; set; }
public List<Task> Tasks { get; set; }
public int RequestedBy { get; set; }
public int CategoryId { get; set; }
public int ProjectedCompletionMinutes { get; set; }
public Group()
{
CreateDate = DateTime.UtcNow;
Active = false;
XIndex = 1;
YIndex = 1;
}
}
}
As you can see all I want to do here is to return the amount of Groups that exist in my collection. I can confirm there are records in the collection in the database.
No matter what I try it always returns 0. I'm brand new (just started learning today) with Blazor, and equally as new with core. I've used LiteDB on a similar project.
To be honest I'm not sure if i'm even making a connection with my LiteDB. I have tried to insert into the db but that also does nothing. Which would point me to an issue with the connection string, but I've just copied the path from the .db file and used that.
Any suggestions?