Optimize the method: Abp.Organizations.OrganizationUnitManager.ValidateOrganizationUnitAsync(OrganizationUnit organizationUnit)
See original GitHub issueold: ` protected virtual async Task ValidateOrganizationUnitAsync(OrganizationUnit organizationUnit) { var siblings = (await FindChildrenAsync(organizationUnit.ParentId)) .Where(ou => ou.Id != organizationUnit.Id) .ToList();
if (siblings.Any(ou => ou.DisplayName == organizationUnit.DisplayName))
{
throw new UserFriendlyException(L("OrganizationUnitDuplicateDisplayNameWarning", organizationUnit.DisplayName));
}
}
`
new: ` protected virtual async Task ValidateOrganizationUnitAsync(OrganizationUnit organizationUnit) { var siblings = (await FindChildrenAsync(organizationUnit.ParentId)) .Where(ou => ou.Id != organizationUnit.Id && ou.DisplayName == organizationUnit.DisplayName).Any();
if (siblings)
{
throw new UserFriendlyException(L("OrganizationUnitDuplicateDisplayNameWarning", organizationUnit.DisplayName));
}
}
`
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Class OrganizationUnitManager - ABP Documentation
Performs domain logic for Organization Units. ... Declaration. protected virtual Task ValidateOrganizationUnitAsync(OrganizationUnit organizationUnit) ...
Read more >Organization Unit Management
The OrganizationUnitManager class can be injected and used to manage OUs. Common use cases are: Create, Update or Delete an OU; Move an...
Read more >Extending Organization Unit #4973
I am using ASP.NET Core v5.3 jQuery. I am trying to extend the OrganizationUnit entity to include a boolean called IsOrganizer. I followed...
Read more >What is organizational unit (OU)? | Definition from TechTarget
An organizational unit (OU) is a container within a Microsoft Active Directory domain which can hold users, groups and computers.
Read more >Managing organizational units (OUs) - AWS Organizations
You can use organizational units (OUs) to group accounts together to administer as a single unit. This greatly simplifies the management of your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
但,这个是同步方法啊。换用异步方法,不是更快吗?
For reference: OrganizationUnitManager.cs#L123-L133
Any
is faster thanCountAsync
.Where
instead of&&
for clarity==
My suggestion:
Note: You can use
```c#
for code blocks with syntax highlighting.