user2585299
user2585299

Reputation: 883

Breeze .expand fetching null for navigation property

   public class Denial
{
    [Key]
    public string DenialCd { get; set; }
    [Required]
    public string DenialDesc { get; set; }

    public ICollection<CaseDenial> CaseDenials { get; set; }
}


public class CaseDenial
{
    [Key]
    public int ID { get; set; }

    [Required]
    public string DenialCd { get; set; }

    [Required]
    public int CaseId { get; set; }

    [ForeignKey("DenialCd")]
    public Denial Denial { get; set; }
    [ForeignKey("CaseId")]
    public Case Case { get; set; }
}

      var query = EntityQuery.from('CaseDenials')
            .where("CaseId", "==", caseID)
            .expand("Denial")
            .orderBy("DenialCd").inlineCount();

CaseDenial table links to DenialCd column of Denial table. Above breeze query brings null for the navigation property "Denial" while fetching records from CaseDenials.

Upvotes: 1

Views: 215

Answers (2)

Dominictus
Dominictus

Reputation: 721

As far as I know, if you have 1 denial with MANY case denials, then you should query as follows:

var query = EntityQuery.from('Denials')
    .where("CaseDenial.CaseId", "==", caseID)
    .expand("CaseDenial")
    .orderBy("DenialCd").inlineCount();

This should work. What you can try as well is adding [InverseProperty("CaseDenials")]

Upvotes: 1

Jay Traband
Jay Traband

Reputation: 17052

My guess is that your EF model is not attributed 'correctly'. I would confirm that you can perform a server side Entity Framework 'Include' operation. This is what Breeze is doing under the covers when you call a client side 'expand'.

Upvotes: 1

Related Questions