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

后端 未结 6 1629
清酒与你
清酒与你 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:47

    Create a Query Object and pass it to your services.

    See if this helps:

    http://ruijarimba.wordpress.com/2011/05/09/entity-framework-and-t4-generate-query-objects-on-the-fly-part-1/

    An example:

    var search = new AlbumSearch();
    search.PriceFrom = 5;
    search.PriceTo = 10;
    search.Artist = new ArtistSearch(){ Name = "Metallica" };
    search.Genre = new GenreSearch(){ NameContains = "Metal" };
    
    var albuns = from x in repository.All(search.GetExpression())
                      select x;
    

提交回复
热议问题