【发布时间】:2019-10-10 17:12:36
【问题描述】:
我有以下架构:
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;
使用模型上下文有什么方法吗?而不是链接
【问题讨论】: