Unable to Load related Entities/Documents Successfully in Marten

This seems like a simple problem but I have been having a challenge loading a document via the entity with related document with Marten documentDB on postgres for the past 2 days. I’m also using the latest release of the library (7.26.0). Please patiently go through my work so far:

KycVerificationStep (Entity)

public class KycVerificationStep : BaseEntity
{
    public Guid Id { get; set; }
    public string Code { get; private set; }
    public string Name { get; set; }
    public string Description { get; private set; }
    public string Icon { get; private set; }
    public int Order { get; private set; }
    public DateTimeOffset DateCreated { get; private set; }
    public DateTimeOffset? DateUpdated { get; private set; }

    private KycVerificationStep() { }

    private KycVerificationStep(
        string name,
        string description,
        string icon,
        int order,
        IKycVerificationStepDomainService domainService)
    {
        CheckRule(new KycStepMustBeUniqueRule(domainService, name));
        Name = name;
        Description = description;
        Icon = icon;
        Order = order;
        DateCreated = SystemClock.Now;
        Code = $"Step {Order}";

        AddDomainEvent(new KycVerificationStepCreatedDomainEvent(Id));
    }

    public static KycVerificationStep Create(
        string name,
        string description,
        string icon,
        int order,
        IKycVerificationStepDomainService domainService)
    {
        return new KycVerificationStep(name, description, icon, order, domainService);
    }

    // shortened for brevity   
}

MemberKycVerificationStep

public class MemberKycVerificationStep : BaseEntity
{
    public string Id { get; private set; }

    public Guid KycVerificationStepId { get; private set; }

    public KycVerificationStep KycVerificationStep { get; private set; }

    public Guid MemberId { get; private set; }

    public string Status { get; private set; }

    public DateTimeOffset DateUpdated { get; private set; }

    private MemberKycVerificationStep() { }

    private MemberKycVerificationStep(
        Guid kycVerificationStepId,
        Guid memberId)
    {
        Id = $"{memberId}_{kycVerificationStepId}";
        KycVerificationStepId = kycVerificationStepId;
        MemberId = memberId;
        Status = VerificationStatus.NotStarted.ToString();

        AddDomainEvent(new MemberKycVerificationStepCreatedDomainEvent(MemberId, KycVerificationStepId));
    }

    public static MemberKycVerificationStep Create(
        Guid kycVerificationStepId,
        Guid memberId)
    {
        return new MemberKycVerificationStep(kycVerificationStepId, memberId);
    }
}

Here’s how I try to query MemberKycVerificationStep the get the KycVerificationStep By MemberId.

public async Task<Result<IPagedList<MemberKycVerificationStepDto>>> Handle(GetAllVerificationStepsByUserQuery request, CancellationToken cancellationToken)
{
    KycVerificationStep included = null;
    var results = await _querySession
    .Query<MemberKycVerificationStep>()
        .Include<KycVerificationStep>(x => included = x)
            .On(x => x.KycVerificationStepId)
        .Where(x => x.MemberId == request.UserId)
        .Select(x => new MemberKycVerificationStepDto
        {
            KycVerificationStepId = x.KycVerificationStepId,
            Name = included != null ? included.Name : "",
            DateUpdated = x.DateUpdated,
            Status = "x.Status",
            MemberId = x.MemberId
        })
        .ToPagedListAsync(request.PageIndex, request.PageSize, cancellationToken);
    return await Result<IPagedList<MemberKycVerificationStepDto>>.SuccessAsync(results);
}

But I get the following exception which comes from the linq expressions implementation from Marten.

System.ArgumentNullException: Value cannot be null. (Parameter ‘key’)
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.set_Item(TKey key, TValue
value) at
Marten.Linq.Parsing.SelectParser.VisitConstant(ConstantExpression
node) at Marten.Linq.Parsing.SelectParser.Visit(Expression node)
at
System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression
node) at
Marten.Linq.Parsing.SelectParser.VisitBinary(BinaryExpression node)
at Marten.Linq.Parsing.SelectParser.Visit(Expression node) at
System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression
node) at Marten.Linq.Parsing.SelectParser.Visit(Expression node)
at Marten.Linq.Parsing.SelectParser.ReadBinding(MemberAssignment
binding) at
Marten.Linq.Parsing.SelectParser.VisitMemberInit(MemberInitExpression
node) at Marten.Linq.Parsing.SelectParser.Visit(Expression node)
at Marten.Linq.Parsing.SelectParser..ctor(ISerializer serializer,
IQueryableMemberCollection members, Expression expression) at
Marten.Linq.Parsing.SelectorVisitor.ToSelectTransform(Expression
selectExpression, ISerializer serializer) at
Marten.Linq.Parsing.SelectorVisitor.VisitMemberInit(MemberInitExpression
node) at Marten.Linq.Parsing.SelectorVisitor.Visit(Expression node)
at Marten.Linq.CollectionUsage.BuildTopStatement(IMartenSession
session, IQueryableMemberCollection collection, IDocumentStorage
storage, QueryStatistics statistics) at
Marten.Linq.Parsing.LinqQueryParser.BuildStatements() at
Marten.Linq.Parsing.LinqQueryParser.BuildListHandlerT at
Marten.Linq.MartenLinqQueryable1.ToListAsync[TResult](CancellationToken token) at Marten.Pagination.PagedList1.InitAsync(IQueryable1 queryable, Int32 pageNumber, Int32 pageSize, CancellationToken token) at Marten.Pagination.PagedList1.CreateAsync(IQueryable1 queryable, Int32 pageNumber, Int32 pageSize, CancellationToken token) at Marten.Pagination.PagedListQueryableExtensions.ToPagedListAsync[T](IQueryable1
queryable, Int32 pageNumber, Int32 pageSize, CancellationToken token)

The data for the MemberKycVerificationStep document is present in the db. But I don’t understand why I’m getting a null reference. Please help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật