FetchStrategy with anonymous result type

Thread is closed for posting
2 posts, 0 answers
  1. Dmitry
    Dmitry avatar
    8 posts
    Member since:
    Oct 2012

    Posted 14 Mar 2014 Link to this post

    Hi, Telerik.

    I'm using FetchStrategy for getting Collection navigation field values by one query. Eeverything work with code:
    class Program
        static void Main(string[] args)
            var fetchStrategy = new FetchStrategy();
            fetchStrategy.LoadWith<Book>(b => b.Cities);
            using (var ctx = new FluentModel())
                ctx.FetchStrategy = fetchStrategy;
                var books = ctx.Books.Select(b => new { b.Cities }).ToList();

    But if I add to anonymous type field of Books FetchStrategy doesn't work. For Example added b.Name
                using (var ctx = new FluentModel())
                    ctx.FetchStrategy = fetchStrategy;
                    var books = ctx.Books.Select(b => new {b.Name, b.Cities}).ToList();

    What must I do for working FetchStrategy fine in last example?

    Thank you.
  2. Boyan
    Boyan avatar
    100 posts

    Posted 18 Mar 2014 Link to this post

    Hello Dmitry,

    This is the expected behavior of Telerik Data Access - any fetch strategies would not be applied when using projection into anonymous or not persistent types. Additionally, it would prevent Telerik Data Access from utilizing its caching system. For these reasons I would recommend you to not to use projections unless you absolutely need to.

    Should you have any more question do not hesitate to contact us again.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top