I have a question on related data in tables using Entity Framework. I have 2 tables "customer" && "customerpreferences", since both tables have customer, then the primary key is "Id_Cus". I reviewed eager, lazy loading. It was decided to use eager loading. My service implements the REST architecture on WCF. I would like to know whether it is necessary to write (Include (a => a.customerpreferences)) in each of the methods. And another question, in the screenshots attached below, I checked out where I inserted the expression described above, but this did not work, could you tell me where to put this expression. Thank you in advance!
My code for 3rd image
-
-
-
-
-
-
-
-
-
- namespace WcfRestFullService.Model
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Web;
-
- [DataContract]
- public partial class customerpreference
- {
- [DataMember]
- public int Id_Cus { get; set; }
- [DataMember]
- public int Id_Res { get; set; }
- [DataMember]
- public string Name_Dis { get; set; }
- [DataMember]
- public int Id_Type { get; set; }
-
- public virtual customer customer { get; set; }
- public virtual order order { get; set; }
- public virtual type_dishes type_dishes { get; set; }
- }
- }
-
-
-
-
-
-
-
-
-
- namespace WcfRestFullService.Model
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Web;
-
- [DataContract]
- public partial class customer
- {
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
- public customer()
- {
- this.dishesrankings = new HashSet<dishesranking>();
- this.orders = new HashSet<order>();
- }
-
- [DataMember]
- public int Id_Cus { get; set; }
- [DataMember]
- public string FirstName_Cus { get; set; }
- [DataMember]
- public string LastName_Cus { get; set; }
- [DataMember]
- public int PhoneNum_Cus { get; set; }
- [DataMember]
- public string Email_Cus { get; set; }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public virtual ICollection<dishesranking> dishesrankings { get; set; }
- public virtual customerpreference customerpreference { get; set; }
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public virtual ICollection<order> orders { get; set; }
- }
- }