Это что у меня пока получилось:
Код: Выделить всё
public class PropertiesIndex : AbstractMultiMapIndexCreationTask
{
public PropertiesIndex()
{
// Map for Property
AddMap(properties => from property in properties.Where(x => x.Status < 2)
select new PropertyIndexResult
{
Id = property.Id,
Images = new List()
});
// Map for PropertyImage
AddMap(images => from image in images
select new PropertyIndexResult
{
Id = image.PropertyId,
Images = new List { image }
});
// Reduce function
Reduce = results => from result in results
group result by result.Id into g
select new PropertyIndexResult
{
Id = g.Key,
Images = g.SelectMany(x => x.Images ?? new List()).ToList()
};
StoreAllFields(FieldStorage.Yes);
}
}
Код: Выделить всё
public class PropertyIndexResult
{
public long Id { get; set; }
public List
? Images { get; set; } = [];
}
Код: Выделить всё
public class PropertyImage
{
public long PropertyId { get; set; }
public string? Url { get; set; }
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... child-list