New Posts New Posts RSS Feed: Custom filter methods in LINQ statement
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Custom filter methods in LINQ statement

 Post Reply Post Reply
Author
philcockfield View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Jun-2009
Posts: 19
Post Options Post Options   Quote philcockfield Quote  Post ReplyReply Direct Link To This Post Topic: Custom filter methods in LINQ statement
    Posted: 18-Jun-2009 at 3:45pm
Damn! OK, thanks for looking into thie Eileen.
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 18-Jun-2009 at 11:14am
Unfortunately, custom filter routines/custom extension methods, etc. are not supported by the Entity Framework's LINQ to Entities. This was taken from a blog (http://mosesofegypt.net/post/LINQ-to-Entities-what-is-not-supported.aspx):
 
"By design, LINQ to Entities requires the whole LINQ query expression to be translated to a server query. Only a few uncorrelated subexpressions (expressions in the query that do not depend on the results from the server) are evaluated on the client before the query is translated. Arbitrary method invocations that do not have a known translation, like GetProducts() in this case, are not supported." - Diego Vega, a Program Manager at Entity Framework Team
Back to Top
philcockfield View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Jun-2009
Posts: 19
Post Options Post Options   Quote philcockfield Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2009 at 8:36pm
I'm building out a PersitenceService as per the example in the PrismExplorer.

I have a query that looks like this:

   query = Manager.People
          .Where(p => p.LastName.ContainsAny("smith bell", " "));


The 'ContainsAny' is my own extension method. DevForce is throwing errors saying it can't find it, which makes sense as it's probably not the same assembly name on the server. An alternative I tried was putting this 'ContainsAny' as a static method on the [Person] object itself, which IS shared between the SL client and the server.

This then caused DevForce to throw an Linq exception saying it could not execute the method.

So my question is, what is the approach for calling out to custom filter routines within a LINQ statement?

Thanks!
---
Phil
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down