Hi,
Fetching entire PageData objects from the Find index is "unsupported" as:
a) Deserializing PageData from JSON is, as you're experiencing, hard.
b) Retrieving a PageData object from a source other than EPiServer's API would be risky business. Imagine that you pass such an object to a method in which some other developer later on decides to clone it, modify it and save it.
c) Retrieving all of the content from the index means passing quite a lot of data over the wire. By using GetContentResult all that's passed is the page's ids and since the pages are likely to be in the cache retrieving them from the CMS's API doesn't add much overhead.
So, the recommendation is to either use GetContentResult or use a projection using Select when you don't need the full object.
When calling GetResult I only get a error:
If I use GetContentResult or GetPageResult everything is fine, but the gives unwanted overhead, since all the data wanted already should be indexed in the find base. We tried using a .select, but then we would have to select every field, and we want all of them :)
// Code crashing
var query = SearchClient.Instance.Search<NyhetPage>()
.ExcludeDeleted()
.CurrentlyPublished()
.FilterOnReadAccess()
.Take(antall)
.Skip(skip);
var nyheter = query.GetResult();
// NyhetPage, short version, removed all uninteresting code (like Display and comments)
// PageDataBase is essentially EPiServers PageData with some helper functions, but no Properties
public class NyhetPage : PageDataBase
{
[Required]
[Editable(true)]
public virtual XhtmlString LeadParagraph { get; set; }
[Editable(true)]
public virtual XhtmlString Content { get; set; }
[Editable(true)]
[UIHint(UIHint.Image)]
public virtual Url Image { get; set; }
[Editable(true)]
public virtual ContentArea ReadMore { get; set; }
[UIHint("DropDownStyle")]
[DropDown(Settings = new[]{
"Kategori1|Kategori1",
"Kategori2|Kategori2",
"Kategori3|Kategori3"
})]
public virtual string Kategori { get; set; }
}
// Trace