views:

163

answers:

1

As an example, assume the following simple model:

public class Order
{
    public List<LineItem> LineItems { get; set; }
    public List<Fee> Fees { get; set; }
}

public class LineItem { }
public class Fee { }

With RIA Services, if I want to retrieve an Order and include all of it's line items in the same network call, I can statically place an [Include] attribute on the above LineItems collection. This works great for a single scenario, but what happens when I need multiple "include strategies"?

For instance, one situation might call for including the Fees collection and NOT the LineItems collection. Is there any way with RIA Services to control what's included at runtime without redefining your model and/or creating dtos with the attributes statically placed for each use-case?

A: 

You would do this like that:

var product = _productRepository.GetProductSet()
.Include("Tags")
.Include("Attachments")
.Include("Comments")
.Include("Comments.User")
.Include("Comments.User.UserDetails")
.FirstOrDefault(p => p.ProductId == productId);
Jonx