开发者

If my Service Returns an IEnumerable of Entities, can I Lazy Load Related Entities?

I have this entity:

public class Product
{
    public string Name { get; set; }
    public double Price { get; set; }

 开发者_StackOverflow社区   public ProductManufacturer Manufacturer { get; set; }
}

I want my Services to return a list of Products to display in a View. I also need to display information about the related manufacturer (Product.Manufacturer) using lazy loading.

Should my Services return an IQueryable or an IEnumerable? Thank you.


IEnumerable<T> and IQueryable<T> are both interfaces. Neither of them "support" lazy loading.


I think the items are not serialized before you use them, if that's what you mean. I have had issues with this, returning LINQ expressions from WCF services, and gotten exceptions when the WCF serializer tries to serialize the result. The solution is to call ToArray() on the IQueryable result before serializing it.

Don't know if that completely answers your question?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜