Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim C 161 posts 528 karma points
    Aug 25, 2016 @ 08:19
    Tim C
    1

    Updating documents via razor code?

    From time to time, with any CMS we come across the need to mass update a set of documents in some way - something needs changing that we hadn't planned for. For example a mass replace of the values in a specific property on a number of pages.

    I have looked at the SQL tables in Umbraco and could probably do it via Transact-SQL but I know this wouldn't update the XML cache in server memory, so would presumably need to restart the application which is not ideal.

    Can it be done from Razor code on a page, or some C# code in App_code?

  • David Peck 690 posts 1896 karma points c-trib
    Aug 25, 2016 @ 11:01
    David Peck
    0

    A few idea:

    1. Migrations
    2. Just calling a controller
    3. LinqPad

    For all of the above you'll then need to use the ContentService, which is a back office API, to call, edit and save your changes.

    Don't use Razor though. That is for use in the views and for the purpose of rendering HTML.

  • Tim C 161 posts 528 karma points
    Aug 25, 2016 @ 11:04
    Tim C
    0

    Thanks, David

Please Sign in or register to post replies

Write your reply to:

Draft