0

私は次のスキーマを持っています:

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;

モデルのコンテキストを使用してそれを行う方法はありますか? リンクの代わりに

4

2 に答える 2

0

私があなたの質問を理解した場合、次の文で十分です FALSE を追加する必要はありません if (context.Provider.Any(o => o.User.Email == input_mail))

于 2019-10-10T17:29:40.110 に答える