Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Unable to cast block type to IContent

Vote:
 

I'm doing an episerver find indexing job where I want to take all blocks of type PersonBlock and create a new object which will be searchable. To save it to the index i need the blocks Id which I could get if i casted the blocktype to IContent but for some reason it's not working?

I've read this post already: http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=77662&epslanguage=en which claims that it's not possible to cast it to IContent if it's a local block but this block is never used as a local block.

Maybe this has something to do with how i retrieve all my blocks

SearchClient.Instance.Search<PersonBlock>().Take(1000).GetResult()

If so, I'm all ears how I can retrieve all my blocks of this type in a different way

 

#82786
Mar 19, 2014 16:21
Vote:
 

Have you tried GetContent() instead?

#82789
Mar 19, 2014 17:59
Vote:
 

That worked. Thanks!

#82803
Mar 20, 2014 8:33
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.