This repository provides a library that allows to build expressions of only .Include
and .ThenInclude
methods.
Install from NuGet
Install-Package EFCore.IncludeByExpression
using EFCore.IncludeByExpression;
static void Main(string[] args)
{
var nodes = GetNodes(x => x.Include(y => y.Childs).ThenInclude(y => y.Parent));
}
static IEnumerable<Node> GetNodes(NavigationPropertyPath<Node>? navigationPropertyPath = null)
{
return DbContext.Nodes.IncludeByExpression(navigationPropertyPath).ToList();
}