如何连接来自 IdentityDbContext 和 ApplicationDbContext 的表
How to join tables from IdentityDbContext and ApplicationDbContext
如何将 AspNetUsers 加入我的 tables,其中电子邮件已从 AspNetUsers table
确认
正在从 table 个已确认电子邮件的 AspNetUsers 中选择用户
var context = new IdentityDbContext();
var users = context.Users.Where(d => d.EmailConfirmed == true).Select(d => d.Id).ToList();
我的table
ApplicationDbContext db = new ApplicationDbContext();
UserAccountListViewModel model = new UserAccountListViewModel();
model.UserAccounts = db.UserAccounts.ToList();
您可以进行如下操作:
UserAccountListViewModel model = new UserAccountListViewModel();
model.UserAccounts = db.UserAccounts.Where(ua => users.Contains(ua.Id)).ToList(); // Here `ua.Id` is the column of `UserAccount` table that you are comparing against the Id of Users table.
如何将 AspNetUsers 加入我的 tables,其中电子邮件已从 AspNetUsers table
确认正在从 table 个已确认电子邮件的 AspNetUsers 中选择用户
var context = new IdentityDbContext();
var users = context.Users.Where(d => d.EmailConfirmed == true).Select(d => d.Id).ToList();
我的table
ApplicationDbContext db = new ApplicationDbContext();
UserAccountListViewModel model = new UserAccountListViewModel();
model.UserAccounts = db.UserAccounts.ToList();
您可以进行如下操作:
UserAccountListViewModel model = new UserAccountListViewModel();
model.UserAccounts = db.UserAccounts.Where(ua => users.Contains(ua.Id)).ToList(); // Here `ua.Id` is the column of `UserAccount` table that you are comparing against the Id of Users table.