This is a migrated thread and some comments may be shown as answers.

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

1 Answer 63 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Frumkin
Top achievements
Rank 1
Daniel Frumkin asked on 21 Dec 2012, 11:08 PM
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? 

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 26 Dec 2012, 01:15 PM
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.
Tags
Web Services
Asked by
Daniel Frumkin
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or