This repository provides a library that allows to build expressions of only .Include
and .ThenInclude
methods.
Install from NuGet
Install-Package EFCore.IncludeByExpression
Abstractions can be installed from NuGet
Install-Package EFCore.IncludeByExpression.Abstractions
using EFCore.IncludeByExpression;
using EFCore.IncludeByExpression.Abstractions;
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();
}