This is my Model for a directory
public class Repositories
{
public string Id { get; set; }
public string ParentId { get; set; }
public string Name { get; set; }
public string ApplicationName { get; set; }
public string ApplicationId { get; set; }
public string Path { get; set; }
public ICollection<Repositories> RepositoryObjectChildren { get; set; }
public DateTime CreatedOn { get; set; }
}
This is how I retrieve the directory tree.
public List<Repositories> GetRepositoryTree()
{
List<Repositories> data = new List<Repositories>();
try
{
data = dbContext.Repositories.Include(x => x.RepositoryObjectChildren).Where(x => x.ParentId == null).ToList();
}
catch (Exception e)
{
logger.LogError(e, LoggingGlobals.NotFound);
data = null;
}
return data;
}
I am unsure of how to continue from here. How do I save to this Model? Specifically how do I save to the ICollection part? My intention is to create a directory of folders with subfolders that may have subfolders.