CreateContent doesn't create the nodeID when you call it, the Identity is set when you save the returned object, the source summarizes it:
/// Note that using this method will simply return a new IContent without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new content objects
/// that does not invoke a save operation against the database.
If you want to create a node and have the ID right-away - then cs.CreateContentWithIdentiy will create the content save it and give you the identiy there and then.
If you want to create something and set so properties then CreateContent is quicker - (as it doesn't save anything to the DB until you tell it to).
Does the content service create content method assign a nodeId
Hi all,
Fairly quick question here. When you call the content service such as the code below:
Is the new content node assigned an Umbraco Id at this point or is it when you actually use the save method on the object?
Hi
CreateContent doesn't create the nodeID when you call it, the Identity is set when you save the returned object, the source summarizes it:
If you want to create a node and have the ID right-away - then cs.CreateContentWithIdentiy will create the content save it and give you the identiy there and then.
If you want to create something and set so properties then CreateContent is quicker - (as it doesn't save anything to the DB until you tell it to).
CreateContent: https://github.com/umbraco/Umbraco-CMS/blob/ab092b8814506e82c22abf6eaef11c04625ae3b6/src/Umbraco.Core/Services/ContentService.cs#L181
CreateContentWithIdentiy: https://github.com/umbraco/Umbraco-CMS/blob/ab092b8814506e82c22abf6eaef11c04625ae3b6/src/Umbraco.Core/Services/ContentService.cs#L281
is working on a reply...