我正在尝试使用 AdventureWorks2012 数据库和 EF 在我的演示应用程序中保持一致,但我需要一些帮助来将此 Linq 语句转换为扩展方法。
return (from person in this.context.Persons
from email in this.context.EmailAddresses
where email.EmailAddress == emailAddress
select person).FirstOrDefault();
对象是:
public class Person
{
public int BusinessEntityId { get; set; }
public string PersonType {get;set;}
public bool NameStyle { get; set; }
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Suffix { get; set; }
public int EmailPromotion { get; set; }
public PersonPassword Password { get; set; }
public virtual ICollection<PersonEmailAddress> EmailAddresses { get; set; }
}
public class PersonEmailAddress
{
public int BusinessEntityId { get; set; }
public int EmailAddressId { get; set; }
public string EmailAddress { get; set; }
public virtual Person Person { get; set; }
}
public class PersonPassword
{
public int BusinessEntityId { get; set; }
public string PasswordHash { get; set; }
public string PasswordSalt { get; set; }
public virtual Person Person { get; set; }
}
其中 BusinessEntityId 是 PK。任何帮助是极大的赞赏。谢谢...