get the contentitem of a specific content type item with known id

Topics: Customizing Orchard
Jun 17, 2013 at 11:29 AM
I want to get the contentItem of a specific content type.I know what the content type is e.g Article and i know the id of this specific article.
How can i get full access to the contentItem?

Maybe it is usefull to notice that i already have access to IContent _item but it does not contain as much data as contentItem.(i m in ItemInspector class in Orchard.Core.Feeds.StandardBuilders)

PS I m writing background code so i do not have access to Model
e.g Orchard.ContentManagement.ContentItem contentItem = Model.ContentItem;

Thanx in advance.
Jun 17, 2013 at 11:32 AM
If you have an IContent object, you have the content item already. IContent has a ContentItem property.
Jun 17, 2013 at 11:42 AM
Edited Jun 17, 2013 at 11:43 AM
Thank you for your answer .Maybe I m little confused.But when I m in a view (.cshtml)
i can write code like this : and i can have access to the desired property.

But when i write background code , contentitem does not contain Article. Article btw is a content type that i created via dashboard.
Is it any other way to have access to Article's properties?
Jun 17, 2013 at 11:45 AM
You can do the same from your class if you cast your content item to a dynamic, e.g.:
var fileName = ((dynamic)contentItem);
Jun 17, 2013 at 11:54 AM
Great!That is what i was looking for.Thanx again!