I have a block of code where a piece of the lambda expression is used again and again. How can store this logic so that i can reuse this expression piece?
Eg: lets take the example of the code given below
Session.Query<DimensionGroup>()(dimgroup=>(dimgroup.Users.Where(map =>
((map.User.Key == _users.PublicUser.Key || map.User.Key == _users.CurrentUser.Key) &&
map.AccessLevel.ToAccessLevel() == AccessLevel.Write)).Count() > 0));
(map.User.Key == _users.PublicUser.Key || map.User.Key == _users.CurrentUser.Key)
being the portion I want to reuse.
and a similar piece of code...
Session.Query<DimensionGroup>()(dimgroup =>(dimgroup.Users.Where(map => ((map.User.Key
==_users.PublicUser.Key || map.User.Key == _users.CurrentUser.Key) &&
map.AccessLevel.ToAccessLevel() == AccessLevel.Read)).Count() > 0));
(map.User.Key
== _users.PublicUser.Key || map.User.Key == _users.CurrentUser.Key)
being the portion I want to reuse.
Is there some way I can reuse just those parts of the expression?