How can I pass a lambda expression to a WCF service?

后端 未结 6 1634
清酒与你
清酒与你 2020-11-29 12:56

My current project is using the IDesign architecture, so all of my layers are services. I wanted to have my Read method in the CRUD of my resource access layer take a predic

6条回答
  •  一个人的身影
    2020-11-29 13:51

    WCF doesn't offer this out of the box. You would essentially have to write a custom serializer that took lambda expressions and turned the expression tree into a serializable piece of data.

    This is how WCF DataServices works. You use lambdas in your client code, it decomposes those lambda expressions into strings which it passes on the querystring to the data service which then turns the string back into a lambda which it applies to a IQueryable on the server side.

    Doable, but you will have to to write a lot of custom serialization code for this. Also, let's be clear, these would be lamdba expressions, not full lambda methods containing random code that could ever be executed on the server side.

提交回复
热议问题