{
Using (var scope=_dbContextScopeFactory CreateReadOnly ())
{
Var db=scope. DbContexts. Get
Var list=db. Menus. The Where (m=& gt; ! M.I sDeleted)
.join (db) RoleMenus, m=& gt; M.I d, rm=& gt; Rm. MenuId, (menu, roleMenu)=& gt; New {menu, roleMenu})
The Where (item=& gt; Item. RoleMenu. RoleId==RoleId)
The Select (item=& gt; Item. The menu). ToList ();
Return _mapper. Map
- List
}
}
One. Join (db RoleMenus, m=& gt; M.I d, rm=& gt; Rm. MenuId, (menu, roleMenu)=& gt; New {menu, roleMenu}) how to understand,
Is there a detailed explanation on this,
Feeling linq is easier to understand,
CodePudding user response:
Open it,A. oin (b,,,,,,,,
A table b table
M=& gt; M.I d, rm=& gt; The rm MenuId,
Id in a table, where m is just a generation refers to
By the same token, the rm representative id, b
Is associated with the column id,
(menu, roleMenu)
The returned result set
//abstract:
//Correlates the elements of two sequences -based on matching keys.
//equality comparer is 2 compare keys.
//
//parameters:
//outer:
//The first sequence to join.
//
//inner:
//The sequence to join to The first sequence.
//
//outerKeySelector:
//A function to extract the join key from each element of the first sequence.
//
//innerKeySelector:
//A function to extract the join key from each element of the second sequence.
//
//resultSelector:
//A function to create A result element from two matching elements.
CodePudding user response:
However, although I use lambda more at ordinary times,But about the join such, I still use linq,
I personally feel looks more transparent,
I might write
Var q=(from a in a
Join in on Anderson d b b equals b.i d
The where...
Select (new {a, b})
). ToList ()
//after may also to lambda
The where (x=& gt; . )
. Take...