Copied to clipboard

Flag this post as spam?

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

  • Eric Schrepel 161 posts 226 karma points
    Jul 29, 2022 @ 00:06
    Eric Schrepel

    MemberService in Umbraco 10 views

    Duplicating a site from v8 to v10 and have most code updated, but this one throws me still. It's just a view to show a photo directory of the intranet members:

    @using Umbraco.Core.Services
    IMemberService memberService = Services.MemberService;
    IOrderedEnumerable<IMember> members;  // THROWS ERROR
    members = memberService.GetMembersByGroup("MainOffice);
    foreach (var member in members) {  // display member photos and such }

    But in v10, I keep getting the error "The type or namespace name 'IMember' could not be found" on the line noted above.

    I've added "@inject IMemberService MemberService" to the top but still no luck. Wondering if there are some other @using or @inject statements I need? Or different syntax entirely? (I've already perused the v10 Sample Docs but no memberservice examples there.)

  • Huw Reddick 1315 posts 4598 karma points c-trib
    Jul 29, 2022 @ 07:21
    Huw Reddick

    Sounds like you haven't included the Umbraco Models as a using, not sure what it is in v9, but in v10 you need

    @using Umbraco.Cms.Core.Models

  • Eric Schrepel 161 posts 226 karma points
    Jul 29, 2022 @ 16:49
    Eric Schrepel

    I had Umbraco.Cms.Core.Models.PublishedContent, forgot to drop back a level to just .Models

    Thanks so much.

  • Singer 4 posts 75 karma points
    Jul 29, 2022 @ 09:49

    The MemberService acts as a "gateway" to Umbraco data for operations which are related to Members. Browse the API documentation for IMemberService. All samples in this document will require references to the following dll: Umbraco. Teco Sign In

Please Sign in or register to post replies

Write your reply to: