我正在尝试使用 linkq 在 ApplicationUser (从 IdentityUser 继承)和另一个模式之间加入。我的 ApplicationUser 类:
namespace ServiceProviderApp.Models
{
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; }
}
}
我的应用上下文文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using ServiceProviderApp.Models;
using ServiceProviderApp;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace ServiceProviderApp.Models
{
public class ServiceProviderAppContext : IdentityDbContext<ApplicationUser,ApplicationRole,string>
{
public ServiceProviderAppContext (DbContextOptions<ServiceProviderAppContext> options)
: base(options)
{
}
public DbSet<ServiceProviderApp.Models.Provider> Provider { get; set; }
...
...
...
...
public DbSet<ServiceProviderApp.Models.ApplicationUser> ApplicationUser { get; set; }
public DbSet<ServiceProviderApp.Models.ApplicationRole> ApplicationRole { get; set; }
}
}
我有以下文件:
public class DummyData
{
public static async Task Initialize(ServiceProviderAppContext context)
{
context.Database.EnsureCreated();
var q = from p in context.Provider
join au in context.ApplicationUser on p.ProviderId equals au.Id
where au.Email == "mm@mm.mm" select au.id;
.....................
在 linq 查询中,“加入”被标记为错误,我收到以下错误:
join 子句中的表达式之一的类型不正确。对“加入”的调用中的类型推断失败。异常:ArgumentNullException。
我在编译时而不是在运行时收到此错误。