CatalogueName = ((IEnumerable<LocalizedLabel>)LoadDocument<Catalogue>(item.CatalogueId).LocalizedName.LocalizedLabels).Select(x => x.LabelText).FirstOrDefault()
Here is my complete map definition:
Map = catalogueitems => from item in catalogueitems
select new
{
CatalogueId = item.CatalogueId,
CatalogueSectionId = item.CatalogueSectionId,
CurrencyCode = item.CurrencyCode,
ExchangeRate = item.ExchangeRate,
CatalogueSectionName = LoadDocument<CatalogueSection>(item.CatalogueId).Name,
ProductVersionName = LoadDocument<ProductVersion>(item.TargetProductVersionId).Name,
ProductId = LoadDocument<ProductVersion>(item.TargetProductVersionId).ProductId,
ProductVersionId = item.TargetProductVersionId,
SKU = LoadDocument<ProductVersion>(item.TargetProductVersionId).SKU,
CatalogueName = ((IEnumerable<LocalizedLabel>)LoadDocument<Catalogue>(item.CatalogueId).LocalizedName.LocalizedLabels).Select(x => x.LabelText).FirstOrDefault()
};
--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
var returnValue = _documentSession.Query<CatalogueItem, ProductListItemWithProductFromCatalogueItem>().AsProjection<ProductListItem>().ToList();
Store(x => x.CatalogueName, FieldStorage.Yes);
I have found the issue that I am trying to project CatalogItem to ProductListItem which is basically a denormalized copy of CatalogItem.
In index I query CatalogItem and uses LoadDocuments to populate denormalized fields in ProductListItem. These denorm fields are obviously not present in CatalogItem.
Therefore when I use AsProjection(ProductListItem) on CatalogItems in query the denormalized fields are not populated because they were not present in CatalogItem.
_documentSession.Query<CatalogueItem, ProductListItemWithProductFromCatalogueItem>().AsProjection<ProductListItem>().ToList();
Does this make any sense?