Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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?
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.