Fluent() Getting to Library from Documents

Posted by Community Admin on 04-Aug-2018 02:37

Fluent() Getting to Library from Documents

All Replies

Posted by Community Admin on 14-Dec-2011 00:00

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);

Posted by Community Admin on 16-Dec-2011 00:00

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

This thread is closed