It seems that lazyloading don't work: there are structure's fields in SQL query.

SectionId works fine.

public class Page : Entity
    [Field, Key]
    public int Id { get; private set; }

    public string Url { get; set; }

    [Field(LazyLoad = true)]
    public int SectionId { get; set; }

    [Field(LazyLoad = true)]
    public PageLocalization Ru { get; set; }

    [Field(LazyLoad = true)]
    public PageLocalization En { get; set; }


public class PageLocalization : Structure
    public string Title { get; set; }

    public string Text { get; set; }

var page = Xtensive.Orm.Session.Demand().Query.Single<Page>(8);

SELECT [a].[Id], [a].[TypeId], [a].[Url], [a].[Ru.Title], [a].[Ru.Text], [a].[En.Title], [a].[En.Text] FROM (SELECT [b].[Id], 103 AS [TypeId], [b].[Url], [b].[SectionId], [b].[Ru.Title], [b].[Ru.Text], [b].[En.Title], [b].[En.Text] FROM [dbo].[Page] [b]) [a] WHERE ([a].[Id] IN (@p1_0_0_0));

asked Apr 19 '12 at 06:38

Ness's gravatar image


One Answer:

Hello Ness,

currently this is by design. IsLazyLoad works only on primitive fields. However such design seems unreasonable for me. We'll discuss with team how this could be changed.

answered Apr 19 '12 at 10:10

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov

We tried it for a reason :)

"DataObjects.Net supports lazy loading for all persistent properties except primary keys: ..... *Structures* – persistent fields where field type is inheritor of Structure; ......"

(Apr 19 '12 at 11:38) Ness Ness's gravatar image

Seems like a failure on our side :-) Probably author was not aware of actual behavior. I've checked a source code and change history. There is a check for field.IsPrimitive. It was there for at least 2 years.

(Apr 19 '12 at 14:49) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Ok, we'll wait for "structure lazyloading" feature :)

(Apr 20 '12 at 03:49) Ness Ness's gravatar image

You can convert PageLocalization to Entity if you absolutely need lazy-loading here.

Our localization extension ( does so for example.

(Apr 20 '12 at 04:42) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

We had tested your realization but found, that behavior are not suitable for us in some cases.

By the way, where you can discuss DO extensions?

(Apr 20 '12 at 05:29) Ness Ness's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA