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
I had a macro working for Umbraco V7 which read a list of countries from custom table and displayed as HTML select on website. Can you please give an example how it can be achieved in Umbraco V8?
I cannot access the db context on custom controller and call the controller from partial view macro in V8 anymore.
I think in V8 you can access the database to run custom queries against a custom table via using a Scope...
There is a ScopeProvider that has the job of creating a 'scope' object from which you can access the IUmbracoDatabase or run your SQL...
You can 'inject' the ScopeProvider into your custom controller...
So something like this:
public class CountriesController : SurfaceController
private readonly IScopeProvider scopeProvider;
public CountriesController(IScopeProvider scopeProvider)
this.scopeProvider = scopeProvider;
// GET: Countries
public ActionResult GetCountries()
using (var scope = scopeProvider.CreateScope(autoComplete: true))
var sql = scope.SqlContext.Sql()
var countries = scope.Database.Query<MyCountryTable>(sql);
var vm = new CountriesListViewModel();
vm.Countries = countries;
return View("CountriesListPartial", vm);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted