Loading Navigation Properties into DTO (using the plain WCF web service)

2 posts, 0 answers
  1. Daniel Frumkin
    Daniel Frumkin avatar
    19 posts
    Member since:
    Jun 2004

    Posted 21 Dec 2012 Link to this post

    I'm trying to extend the generate WCF plain service with some of my own custom logic.  I want to add a function that takes a DTO object, gets a list of entities from a navigation property and runs a query against the repository based on the entities returned from the navigation property.   


    I've added a method to the .svc and to the service.cs layer.

    How do I get my Dto's be loaded with the navigation properties?  Or is the way I'm going about extending the service all wrong?


    // method added to the .svc
    public IEnumerable<ProductDto> ReadProductByBrandGroup(BrandGroupDto brand){
        var mappings = brand.BrandMappings.ToList(); //this should return a list of strings but instead returns null
        return this.ProductService.FindProductsByBrandGroup(brand); //this works
    }
     
    //method added ProductService class in the service.cs layer
    public IEnumerable<ProductDto> FindProductsByBrandGroup(BrandGroupDto brandGroup)
    {
       var bMaps = brandGroup.BrandMappings;  
       List<string> brandNames = bMaps.Select(x=>x.BrandName).ToList<string>() ;
       var query = this.Find(x => brandNames.Contains(x.BrandName));
       return query;
    }


    I've excluded code added to the IProductService and the [OperationContract] for ReadProductByBrandGroup

    UPDATE:  Did a little more digging and found the solution.  http://www.telerik.com/help/openaccess-orm/developer-guide-wcfservices-plain-service-handle-relationships.html


    (ps: um how do you remove formatted code blocks from your post? 
  2. Viktor Zhivkov
    Admin
    Viktor Zhivkov avatar
    291 posts

    Posted 26 Dec 2012 Link to this post

    Hi Daniel,

    The documentation article that you have found should demonstrate the behaviour that you want to achieve. Can you confirm that you have found the solution that you have been looking for?

    If you need any assistance with this or any other tasks involving OpenAccess, please do not hesitate to contact us again.

    Kind regards,
    Viktor Zhivkov
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  3. DevCraft banner
Back to Top