I am using Entity Framework Core and I have the following:
String expression = "Country;User;User.Country"
This indicates to include Country, User and User.Country in a query:
var q = context.Jobs
.Include(x => x.Country)
.Include(x => x.User).ThenInclude(x => x.Country);
I do not know what expression will contain. I just know it will be a list of entities, with or not child entities (ex: User.Country) and I need build the Include expression.
Is there a way to do this?
there is two way to call include method. one is with expression and the other is with string.
String expression = "Country;User;User.Country"
string includes = expression.split(';');
var q = context.Jobs;
foreach (string include in includes)
q = q.Include(include);