x First time here? Check out the FAQ
Join us a the Umbraco event of the year - get your Codegarden 14 early bird ticket today

Difference between Node and Document

    Even experienced Umbraco developers may be confused about the difference between the Node class and the Document class.

    Both Nodes and Documents can be fetched using an ID and they both also have the GetProperties method.

    Document document = new Document(id); 

    umbraco.cms.businesslogic.property.Property documentProperty = document.getProperty("propertyName");

    Node node = new Node(id);

    umbraco.presentation.nodeFactory.Property nodeProperty = node.GetProperty("propertyName");

    The real difference between these examples is the data that is being fetched. When you fetch a property using a Document you get the data which is stored inside the database. When you fetch a property using a Node you only get the data which has been published and cached (and stored inside the umbraco.config file). For this reason, Document should be used when it is necessary to modify the data, whereas Node should be used when data simply needs to be retrieved in a read-only fashion.

    Document:

    Document document = 
    new Document(Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]));

    Node:

    Node node = 
    Node.GetCurrent();