Here you ask a lot of different questions.
When developing with umbraco, Umbraco often embed external data into your website. If we already tell you that you can use (almost) any type of data access that you use in simple .Net projects.
Do not lose your context umbraco
This is important when retrieving external data (e.g.) that does not lose your umbraco context . You still have a cracker for rendering, css classes for the active menu for customization, etc. Your "external data" belongs probably below the node. To do this, itβs nice to use standard MVC controllers.
Dirty razor
Since your views are in razor, you can put every external data retrieval in @ {...} in your opinion. If you are not an experienced programmer, this works. Despite the fact that the topics about the principles of maintenance and DRY are doubtful :-)
RenderMvcController and SurfaceController
When you use the RenderMvcController , you basically create a controller for a specific type of document. Every time umbraco displays a node of this type of document. This controller will be called, and the model you render is sent back to the view. As you might have guessed, this is one of my favorite places to extract data and click on it. A surface controller , on the other hand, is a partial view controller, very well crafted by the postback method. Both of these controllers can be used for the interface of your website, and not for the backend.
Inherit your ideas
You can do what you want with your views. But if you inherit your view from UmbracoViewPage, you still have the @Umbraco.Whatever power available in your views
Your URLs remain the same
Since you are "capturing" the route using the RenderMvcController, you can simply trust the umbraco backend to get to the correct URL. The query can be used to retrieve the external data that you want.
Other controllers or methods
Sometimes, if I cannot use the controller above, I create extentionMethod on an IPublishedContent. For example, I can write code like this:
foreach (var myObj in Model.Content.GetMyExternalData()) {
If you need to provide data (using the webApi wrapper), try the UmbracoApiController . This pure REST sang.
Access data in umbraco
You should know that Umbraco uses petapoco as an ORM. Therefore, you can (and should) consider using it. You can reuse the database connection without any problems.
var query = new Sql().Select("*").From("myCustomTable").Where<MyModel>(x => x.Id == id); return DatabaseContext.Database.Fetch<MyModel>(query).FirstOrDefault();