0

I do not know Why breeze.js is not showing all my data from my database table, fields with navaigation property from applicationUsers in ASP Identity are returned undefined but when i query the breeze controller resource endpoint on the server all is fine http://prntscr.com/7be8af

I dont know is this have anything to do with ASP Identity or some thing is wrong with my code. The following are the need information.

/// User rehistration model for Patients and Doctors
public class ApplicationUser : IdentityUser
{

    [Required]
    [MaxLength(100)]
    public string FirstName { get; set; }

    [Required]
    [MaxLength(100)]
    public string LastName { get; set; }

    public virtual ICollection<Allergy> PatientAllergy { get; set; }
}


public class Allergy
{
    public int Id { get; set; }
    public string PatientId { get; set; }
    public string DoctorId { get; set; }
    public int LookupAllergyId { get; set; }
    public string Type { get; set; }
    public string Note { get; set; }

    public virtual LookupAllergy LookupAllergy { get; set; }//Navigation prop 1

    /// <summary>
    /// This section is from ASP.Net Identity
    /// </summary>
    [ForeignKey("PatientId")]
    public virtual ApplicationUser Patient { get; set; } //Navigation prop 2
    [ForeignKey("DoctorId")]
    public virtual ApplicationUser Doctor { get; set; }//Navigation prop 3

}

/// This is my configuration model
public class AllergyConfiguration : EntityTypeConfiguration<Allergy>
{
    public AllergyConfiguration()
    {
        HasRequired(s => s.Patient)
           .WithMany(p => p.PatientAllergy)
           .HasForeignKey(s => s.PatientId)
           .WillCascadeOnDelete(false);
    }
}

/// This is my angular Query using John Papa Code pattern johnpapa.net 
function getPatientAllAllergy() {
        var self = this;
        var allergy;
        var orderBy = 'type';

        return EntityQuery.from('Allergies')
            .select('id, lookupAllergyId, patientId, doctorId, type, note')
            .toType(entityName)
            .using(self.manager).execute()
            .then(querySucceeded, self._queryFailed);

        function querySucceeded(data) {
            allergy = data.results;
            self.log('Retrieved [Rev Allergy] from remote data source', diagnosis.length, true); 
            ///if i inspect the information from the log i found that patientId and doctorId are undefined while lookupAllergyId is return.
            return allergy;
        }
    }

The query return all other entity data but patientId and doctorId was undefined while patient and doctor was 'proto._setCtor.instanceProto'

Query from the server return this
PatientId: "a0bb54a2-c347-424c-bbf3-7c05e0286b43", 
DoctorId: "a0bb54a2-c347-424c-bbf3-7c05e0286b43",  
LookupAllergyId: 1 // return ok

Query from the client return this
id: (...)
doctor: proto._setCtor.instanceProto
doctorId: undefined // return undefined
lookupAllergy: (...)
lookupAllergyId: 1
modifiedBy: (...)
modifiedById: (...)
modifiedOn: (...)
note: (...)
patient: proto._setCtor.instanceProto
patientId: undefined // return undefined
type: (...)

Please, i need help on how to resolve this because my navigation query is returning null for example {{vm.allergy.patient.email}} is not possible.

Thanks.

0 Answers0