Join not working as expected (Entity Framework)

c# entity-framework-core identity linq

Question

I'm at a loss as to how to use entity framework to combine these two tables based on UserName.

Both the statement and the procedure I attempted didn't work.

The same user is undoubtedly present in the tables.

var employees = _context.Employees.Include(e => e.Loc);

//Only show employees with a user role of manager
var managerUsers = await _userManager.GetUsersInRoleAsync("Manager");

var match = (from e in employees
                     join m in managerUsers on e.UserName equals m.UserName
                     select new { Employee = e }).ToList();

the breakdown of short codes The database context provides me with a list of all the workers. I search the user roles for a list of people who have the Manager position. I attempted to connect them using the UserName column in the Employee form. Currently, just one manager with a matching username is returning successfully in both tables; however, after applying this code, match produces nothing.

I also tried it this way:

employees.Join(managerUsers,
               e => e.UserName,
               m => m.UserName,
               (e,m) => new { e }).ToList();   

However, it likewise doesn't provide any results. Why am I misusing this?

1
0
1/14/2019 11:37:54 AM

Popular Answer

ZZZ_tmp
0
1/14/2019 2:39:31 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow