use of an Expression in a LinqToSQL Query

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Good moring,

I have an expression I would like to use in a LinqToSQL query.
Here is the expression:
<pre class="prettyprint Expression<Func<string, string, OSRights, bool>> HasRightToViewDocument = (docSourceStr, docCompanyCTCode, userRights) =>
(docSourceStr == "A") ? (userRights.A || (userRights.ARestricted && docCompanyCTCode == userRights.CompanyCTCode)) : false;[/code]
and here is the linq query:
var v = from d in docs where HasRightToViewDocument(d.Str1, d.Str2, userRights) select d;
But it seems I cannot do like this. Could you please explain me why? and correct me if there is solution?

Note: I dont want to make something like docs.Where(HasRightToViewDocument).Select, because in reality my query is more complexe (with some join and a lot of other where clauses :-) )
Many thanks,

View the full article
 
Back
Top