Entity framework navigation property's

You can use Entity Framework navigation property's to query related records. These navigation property's are default eager loading meaning they are loaded if the navigation property is used. This class for example has a related record in the CustomerStatus table based on the CustomerStatusId:

    public class ContactPerson
    {
        public int Id { get; set; }

        public string Firstname { get; set; }

        public string PreFix { get; set; }

        public string LastName { get; set; }

        public DateTime BirthDate { get; set; }

        public int? ContactPersonStatusId { get; set; }

        public RecordDetail RecordDetail { get; set; }

    }

Now it's easy to create a navigation property:

    public class ContactPerson
    {
        public int Id { get; set; }

        public string Firstname { get; set; }

        public string PreFix { get; set; }

        public string LastName { get; set; }

        public DateTime BirthDate { get; set; }

        public int? ContactPersonStatusId { get; set; }

        public virtual ContactPersonStatus ContactPersonStatus { get; set; }

        public RecordDetail RecordDetail { get; set; }

    }

The property must be virtual.

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!