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

FetchStrategy with anonymous result type

1 Answer 16 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dmitry
Top achievements
Rank 1
Dmitry asked on 14 Mar 2014, 06:54 AM
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.

1 Answer, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 18 Mar 2014, 04:45 PM
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.

Regards,
Boyan
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Development (API, general questions)
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Share this question
or