Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Bo Jacobsen 565 posts 2294 karma points
    Jul 24, 2019 @ 14:42
    Bo Jacobsen

    The multi-part identifier cmscontenttype alias could not be bound

    Hi all.

    Using Umbraco 8.1.0

    I am trying to GetPagedChildren from IContentService with a IQuery

    The multi-part identifier cmscontenttype alias could not be bound.

    var filterQuery = Query<IContent>().Where(x => x.ContentType.Alias == "folderAlias");
    var folder = _contentService.GetPagedChildren(1025, 1, 100, out long totalChildren, filterQuery).FirstOrDefault();

    I build my service this way and added it to the composer.

    private readonly IScopeProvider _scopeProvider;
    protected IQuery<T> Query<T>() => _scopeProvider.SqlContext.Query<T>();
    public MyService(IScopeProvider scopeProvider)
        _scopeProvider = scopeProvider;

    I have also tried this way, but it do not return anything.

    var folder = _contentService.GetPagedChildren(1025, 1, 100, out long totalChildren).FirstOrDefault(x => x.ContentType.Alias.Equals("folderAlias"));

    What do i do wrong?

  • Neil Chapman 40 posts 167 karma points
    Dec 03, 2019 @ 09:55
    Neil Chapman

    Did you find a solution to this?

    Currently getting the same error when trying to extend the backoffice contentResource API.

  • Dmitriy Larionov 1 post 21 karma points
    Jan 23, 2020 @ 18:28
    Dmitriy Larionov

    I have the same issue.

  • Bo Jacobsen 565 posts 2294 karma points
    Jan 24, 2020 @ 10:12
    Bo Jacobsen

    I found out that IContentService with a IQuery is very limited. So that aint an option to use like this.

    How ever i got the GetPagedChildren to work if i change 1 to 0.

    like this.

    var folder = _contentService.GetPagedChildren(1025, 0, 100, out long totalChildren).FirstOrDefault();
  • Mats Stam 61 posts 210 karma points
    Sep 23, 2021 @ 12:04
    Mats Stam

    Way late to the party but maybe this helps someone else. This works:

                        var filter = _sqlContext.Query<IContent>()
                            .Where(c => c.ContentTypeId.Equals(YourPageModel.GetModelContentType().Id));
Please Sign in or register to post replies

Write your reply to: