LazyField ContentPicker with value

Topics: Customizing Orchard, General, Troubleshooting, Writing modules
Aug 4, 2015 at 1:50 PM
I have the following setup:
  1. The User content type has a part called 'AuthorPart' (through migrations)
  2. The BlogPostPart has a ContentPickerField (named 'Authors') where you can pick multiple User content items
In the AuthorPart I have the following lazyfield:
internal readonly LazyField<IEnumerable<IContent>> _itemsField = new LazyField<IEnumerable<IContent>>();

public IEnumerable<IContent> Items {
    get { return _itemsField.Value; }
    set { _itemsField.Value = value; }
Now I am trying to setup the lazyfield loader in the AuthorPart handler, but I can't seem to get it to work:
public class AuthorPartHandler : ContentHandler {
    private readonly IContentManager _contentManager;

    public AuthorPartHandler(IContentManager contentManager) {
        _contentManager = contentManager;

    private void SetupAuthorPart(ActivatedContentContext context, AuthorPart part) {

        // Setup the getter of the lazy field
        part._itemsField.Loader(authorPart => {
            // What to do here???
However there are 2 problems with this:
  • The SetupAuthorPart seems to be never called, why is this?
  • I don't know how the query would look like that searches all blogposts that have a contentpickerfield with the name 'Authors' and as one of its values the user id of the AuthorPart
How can I solve this? Or is there a complete other (easy) way to do this?

P.S. I am using the Profile and extended registration module to display a user. On this page I want to show all blogposts that have the user's value in their ContentPickerField 'Authors'.

Thanks for any help!