我有以下架构:
public class Provider
{
[Key]
public int ProviderId { get; set; }
[ForeignKey("ProviderId")]
public ApplicationUser User;
public ICollection<ServiceProvider> Services { get; set; }
}
public class ApplicationUser : IdentityUser
{
public ApplicationUser() : base() { }
public string Name { get; set; }
public string Address { get; set; }
public string Photo { get; set; }
public string BusinessName { get; set; }
}
在我的后端,我有一封电子邮件作为输入,我正在尝试检查是否有任何提供该电子邮件的提供商。我尝试使用以下代码:
if (context.Provider.Any(o => o.User.Email == input_mail) == false)
但我有一个空指针异常..
我知道我可以使用 linku 语法:
var q = from au in _context.ApplicationUser
join p in _context.Provider on au.Id equals p.ProviderId
where au.Email=input_mail;
有什么方法可以使用模型上下文来做到这一点?而不是链接