Click here to Skip to main content
15,947,958 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want a WCF web services with the Web services implementation that returns a list of information in terms of custom queries But an error runs in the Second image Please check tips with respect

<img src="http://i.stack.imgur.com/VlY3m.png" style="width:500;height:350;"/>
<img src="http://i.stack.imgur.com/1c0Ii.png" style="width:500;height:350;"/>

What I have tried:

I want a WCF web services with the Web services implementation that returns a list of information in terms of custom queries But an error runs in the Second image Please check tips with respect
Posted
Updated 2-Mar-16 2:39am

1 solution

You're attempting to serialize a delegate (that Func<> parameter) which isn't supported by .NET defaults. There are ways to get around that:

1) Anonymous Method Serialization[^]) : Only works if your delegate doesn't close over local variables and doesn't include other, non-serializable objects (e.g. an expression tree). (Not tested by me.)

2) InterLINQ[^] : Lets you serialize an expression tree, in general. The actual implementation abstracts the whole querying-process over WCF away, as if the EF-DbContext was available at the client. (I'm using it successfully, not with EF though.)

3) Not pretty, but the only alternative if option 1 doesn't work for you and you shy away from option 2: Instead of expressing your query-predicate in form of a delegate, express it with simple parameters or a class that holds the query parameters - and then build the query server-side from that.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900