Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there an equivalent of
var editors = umbraco.BusinessLogic.User.getAll().Where(u => u.UserType.Alias == "editor");
via the UserService? Visual Studio is telling me that "umbraco.BusinessLogic.User" is obsolete and to use UserService instead.
There is a "getAll()" but it returns a paged list, which is not what I want (I don't think)!?
If you want all of them you make the page size as large as you can:
var userService = Services.UserService; var totalUsers = 0; var allUsers = userService.GetAll(0, int.MaxValue, out totalUsers);
Depending on the number of users you have this may or may not perform well.. ;-)
Hi Sebastian,
Should we copy service instance each time ? Can we use Services.UserService ?
Thanks, Alex
Not sure what you mean? The UsersService is a getter and can be used just about anywhere, you might need to find it in the UmbracoContext:
var usersService = UmbracoContext.Application.Services.UserService;
Goes to this code in Umbraco.Core.Services.ServiceContext:
Umbraco.Core.Services.ServiceContext
/// <summary> /// Gets the <see cref="P:Umbraco.Core.Services.ServiceContext.UserService"/> /// </summary> public IUserService UserService { get { return this._userService.Value; } }
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
UserService equivalent of user.getAll
Is there an equivalent of
var editors = umbraco.BusinessLogic.User.getAll().Where(u => u.UserType.Alias == "editor");
via the UserService? Visual Studio is telling me that "umbraco.BusinessLogic.User" is obsolete and to use UserService instead.
There is a "getAll()" but it returns a paged list, which is not what I want (I don't think)!?
If you want all of them you make the page size as large as you can:
Depending on the number of users you have this may or may not perform well.. ;-)
Hi Sebastian,
Should we copy service instance each time ? Can we use Services.UserService ?
Thanks, Alex
Not sure what you mean? The UsersService is a getter and can be used just about anywhere, you might need to find it in the UmbracoContext:
Goes to this code in
Umbraco.Core.Services.ServiceContext
:is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.