带有EF核心的Linq

时间:2019-05-16 23:43:34

标签: entity-framework asp.net-core asp.net-identity

我如何使用Linq技术在aspNetUsers等asp.net核心中使用身份表 例如

var x = (from a in db.table1 join b in AspNetUsers .... )

1 个答案:

答案 0 :(得分:0)

尝试使用DbContext.Users从IdentityDbContext.cs撤消用户信息:

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of Users.
/// </summary>
public DbSet<TUser> Users { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User claims.
/// </summary>
public DbSet<TUserClaim> UserClaims { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User logins.
/// </summary>
public DbSet<TUserLogin> UserLogins { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User roles.
/// </summary>
public DbSet<TUserRole> UserRoles { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User tokens.
/// </summary>
public DbSet<TUserToken> UserTokens { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of roles.
/// </summary>
public DbSet<TRole> Roles { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of role claims.
/// </summary>
public DbSet<TRoleClaim> RoleClaims { get; set; }

类似的东西:

var categories = from c in db.categories
join u in db.Users
on c.myID equals u.Id
select new { ID=c.myID, name= u.UserName};
var result = categories.ToList();