更新时间:2022-10-16 10:35:39
嗨singhhome,
根据你的描述,我建议你可以创建一个新的customCallDetails并通过Query为它分配值,如下所示:
public class CustomCallDetails
{
public int Id {get;组; }
// ..其他字段。
公共虚拟客户客户{get;组; }
}#Usage:
var result = from p在db.callDetails中
在p.phoneNumber = pn.phoneNumber
上的db.PhoneNumbers中加入pn选择新的CustomCallDetails {id = p.Id,
//其他字段
Customer = db.Cusomter.where(t => t.CustomerId == pn.CustomerId).FirstOrDefault()
};
祝你好运,
Cole Wu
Is there a way I can load an entity based on Lookup data. example, I have 3 tables
in my callDetails entity I want to have a property CallDetails.Customer, and this customer entity should be populated based on lookup on phonenumber value? CallDetails entity only has phoneNumber as a simple string property (it's not of type PhoneNumbers entity)
singhhome
Hi singhhome,
Based on your description, I would suggest that you could create a new customCallDetails and the assign the value to it via Query, like this:
public class CustomCallDetails { public int Id { get; set; } //.. other fields. public virtual Customer Customer{ get; set; } }#Usage:
var result = from p in db.callDetails
join pn in db.PhoneNumbers on p.phoneNumber = pn.phoneNumber select new CustomCallDetails{
id = p.Id,
//other field
Customer = db.Cusomter.where(t=>t.CustomerId == pn.CustomerId).FirstOrDefault()
};
Best regards,
Cole Wu