Jan 23, 2016 at 3:58 PM
Edited Jan 24, 2016 at 10:07 AM
I've written my own module to display and filter wines, It was fine in the beginning but now that there are over 300 contentitems in the database its becoming very slow.
I'm reviewing my code and have noticed that putting these 300 in a viewmodel for filtering on them later on is very slow so i want to get rid of the viewmodel and sort directly.
This is what i have now sorting on the viewmodel: (i have for example a price to sort on = "prijs"
return filteredIDs = AlleWijnenContentItems.AsQueryable().Where(finalquery.ToString()).OrderBy(s => s.prijs).Select(c => c.WijnID).ToList();
I know i can get the price from my contentitem like this:
dynamic contentItem = _contentManager.Get(wijnid);
double prijs = Convert.ToDouble(contentItem.Wijn.Prijs.Value);
But how can I sort directly in the AsQueryable on the contentitem price itself?
I have a IEnumerable list:
Also on the same topic, i was looping over the contenitems to get the terms of the taxonomies, so inside the loop i had this:
List<TermPart> termsvoorcontentitem = _taxonomyService.GetTermsForContentItem(allewijnenIds[tel]).ToList();
Wich x 300 is very costly again, so i replaced it with: (i know the names of the taxonomies and there is only one term allowed)
var drankenterms = contentItem.Wijn.Dranken.Terms;
int kleurid = 0;
foreach (dynamic term in drankenterms)
kleurid = term.Id;
Which is better but still too much code and looping,
I would like to get the id of the term directly
i've tried contentItem.Wijn.Dranken.Terms.Id and also contentItem.Wijn.Dranken.Terms.Elementat(0).id but that doesn't seem to work, how can i get this directly?
Forgive me my noobnes..