1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Fluent() Getting to Library from Documents

Fluent() Getting to Library from Documents

2 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    14 Dec 2011
    Link to this post
    This
    var docs = App.WorkWith()
                                       .Documents()
                                       .Publihed()
                                       .Where(x => x.Library.Title == this.LibraryName)
                                       .Get()

    Fails with this:

    Field 'Library' not found on class 'Telerik.Sitefinity.Libraries.Model.Document


    Why is that not valid?  Is it not an OA managed property?

    I can get around it like this, but it's not that efficient is it?  Like it would transfer it to an inmemory collection right?
    var docs = App.WorkWith()
                                       .Documents()
                                       .Publihed()
                                       .Get()
                                       .ToList()
                                       .Where(x => x.Library.Title == this.LibraryName);
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    16 Dec 2011
    Link to this post
    Hello Steve,

    The reason for the problems might be that the persisted field is Parent, while Library is a property that is internally retrieved as (<T>)this.Parent;  and when you're operating with an IQueryable  the Library property is not available unless you have made a ToList() call beforehand. What I'd recommend you as the correct approach is to use Parent:

    var docs = App.WorkWith()
                                       .Documents()
                                       .Publihed()
                                       .Where(x => x.Parent.Title == this.LibraryName)
                                       .Get()



    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered