I am trying to query the comments that has relationship with request table like this below
public class Request
{
public Guid Id { get; set; }
[Column(TypeName = "jsonb")]
public Correspondence Correspondence { get; set; }
public MasterSection MasterSection { get; set; }
public RequestStatus RequestStatus { get; set; }
public RequestStage RequestStage { get; set; }
public RequestType RequestType { get; set; }
}
and here is my class for correspondence class below
public class Comment
{
public string Text { get; set; }
public string CommentBy { get; set; }
public DateTime CreatedAt { get; set; }
}
public class Correspondence
{
public List<Comment> Comments { get; set; } = new List<Comment>();
}
and here is my linq query to get the results
public IQueryable<Request> GetAllRequests()
{
return _dbContext.Requests.Include(i =>i.RequestStage)
.Include(i =>i.RequestType)
.Include(i =>i.MasterSection)
.Include(i=> i.Correspondence).ThenInclude(i=> i.Comments);
}
but getting an error like Lambda expression used inside Include is not valid. with out including correspondence, the above query is working is fine but when i included the correspondence getting above error.
Is there any other way to get all those related data along with correspondence for the requests
I am using EF core 3.0
Could any one have any idea why i am getting this error and any idea how to overcome this error that would be very grateful to me.
Thanks in advance
sample data

.ThenIncludehave you tried chaining.Include("Correspondence.Comments")?return _dbContext.Requests.Include(i => i.RequestStage) .Include(i => i.RequestType) .Include(i => i.MasterSection) .Include(i => i.Correspondence) .Include("Correspondence.Comment")