Get the Id of just created content type

Topics: Administration, Core, General
Aug 18, 2015 at 9:09 PM
Hi,

I am creating a content type as
_orchardServices.ContentManager.Create(contentTypeName);
This content type may be the parent of some child content type and I am cretaing parent and child at the same time.How would I get the Id of the parent content type after I create it .

Similar to Max(Id) or Last();

Thanks.
Aug 19, 2015 at 10:00 AM
When you use the .Create(string contentType) overload, it returns the newly created content item. Therefore you can just do:
var contentItem = _orchardServices.ContentManager.Create(contentTypeName);
var id = contentItem.Id;