MacroService.GetAll(Guid[]) throws an error
See original GitHub issuePR https://github.com/umbraco/Umbraco-CMS/pull/5962
When I attempt to use the MacroService to get a selection of Macro’s by Guid
, an error is thrown.
Reproduction
Bug summary
When calling MacroService.GetAll
method, passing in an array of Guid
s, the following exception is thrown…
Exception Details:
System.InvalidOperationException
: Cannot run a repository without an ambient scope.
Specifics
Umbraco version: v8.1.0
Stack Trace snippet:
[InvalidOperationException: Cannot run a repository without an ambient scope.]
Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.get_AmbientScope() in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\RepositoryBaseOfTIdTEntity.cs:43
Umbraco.Core.Persistence.Repositories.Implement.MacroRepository.GetBaseQuery() in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\MacroRepository.cs:109
Umbraco.Core.Persistence.Repositories.Implement.MacroRepository.Get(Guid id) in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\MacroRepository.cs:31
Steps to reproduce
- Create a Macro in the back-office, make note of the GUID
- Then, wherever you want to try the C#, controller or Razor view, whichever, try this code…
var guid = new Guid("INSERT-MACRO-GUID-HERE");
var macros = Services.MacroService.GetAll(guid);
foreach (var macro in macros)
{
// do stuff
}
- As soon as the enumerable is evaluated, the exception will be thrown.
Expected result
- I expected a list of Macro objects (by given GUID) to be returned.
Actual result
- The exception, see above.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
unable to render form in richtext editor 30180 umbraco 7 - Contour
2014-01-22 13:38:22,309 [6] WARN umbraco.macro - [Thread 21] Error loading ... but when i add macro to RTE not in Template then its...
Read more >Microservices with ASP.NET Core 3.1 - Ultimate Detailed ...
Create Service with CRUD operations. Create ASP.NET Core Project ; Add Web API versioning. Implement Web API versioning using URL ; Add logging...
Read more >Microservice SDK for Java - Cumulocity IoT Guides
In case of errors, such as invalid names, you will get the details ... Review also the Java example in this guide to...
Read more >EntityController.cs
Document); throw new ArgumentException("Get by query is only compatible with ... Macro: //Get all macros from the macro service; var macros = Services....
Read more >Why I believe Rails is still relevant in 2019
"more error prone and less safe". right there... if I could vote you up a thousand times, I would. I can place a...
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 Free
Top 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
@leekelleher I figured as much. Just thought you should know all the same 😄
Thanks @kjac, I appreciate it! I’ve been meaning to take a look at patching it myself, but it’s already been on my to-do list for 2 months, doh! Thought it best to raise the bug report.
I’m using GUIDs because it’s one less Deploy thing to worry about. (And we’re meant to be “GUID ALL THINGS!” now, right? 😉)
Thanks again for the patch! #h5yr