There are two objects that point to an outdated database; the main object should be accepted in the secondary object using Include and eager data loading. Unfortunately, the object is null, even if SQL Profiling demonstrates that the additional field data is selected correctly .
The essence of the part
[Table("pt_mstr")]
public class QadPart
{
public QadPart()
{
this.PartGroup = new QadPartGroup();
}
[Column("pt_part", Order = 0), Key]
public string Number { get; set; }
[Column("pt_group", Order = 0), ForeignKey("PartGroup")]
public string PartGroupCode { get; set; }
[Column("pt_domain", Order = 1), ForeignKey("PartGroup"), Key]
public string Domain { get; set; }
public QadPartGroup PartGroup { get; set; }
}
EntGroup Entity
[Table("PartGroups")]
public class QadPartGroup
{
[Column("code_value", Order = 0), Key]
public string Code { get; set; }
[Column("code_cmmt")]
public string Name { get; set; }
[Column("code_domain", Order = 1), Key]
public string Domain { get; set; }
}
pt_mstr in essence is a SQL table. PartGroups in a partgroup element is a sql representation.
The part element has a composite key (pt_part, pt_domain). The partgroup object has a composite key (code_value, code_domain).
Linq request
var data = db.Parts.Include<QadPart>(a => a.PartGroup).Where(a => a.Domain == domain && a.Status == "AC").ToList();
The SQL profile shows that all fields are returned, including the PartGroup fields from Include.
"" () , ( PartGroupCode), , PartGroup ( PartGroup.Name PartGroup.Code) null.
P.S. - , , WebApi, WebApi.
, , .