Query Dynamic Content Module right way ?
Maybe this is very basic question, i have 1 dynamic module and with several custom fields such name short text, country related data. Usually i do query :
manager.GetDataItems(typeOfContent).Where(c => c.GetRelatedData<DynamicContent>("country").Where(ct => ct.GetValue<string>("Title").Contains("france"));
it will returning error because iqueryable not ready yet fetching custom field content.
But when i do cast to enumerable it work, fine but quite make page load more slow :
manager.GetDataItems(typeOfContent).AsEnumerable().Where(c => c.GetRelatedData<DynamicContent>("country").Where(ct => ct.GetValue<string>("Title").Contains("france"));
any people have same issue like me ? any suggestion for query with my above conditions to optimizing my content loading.
thanks
In general I can say that LINQ often does not work well with Sitefinity if the query is a bit more complex (e.g. when filtering on properties like in your case or when joining queries). Unfortunately I cast to Enumerable or List all the time. A bug fix request related to LINQ joins can be found here.
Hi Antony,
We believe this is an issue related to a bug we have logged in our feedback portal. For now we recommend to continue using for now the second alternative you mentioned (casting to Enumerable).
You can subscribe to the notifications of this bug report by clicking on the button "Like" to keep updated about the resolution of this issue.
Best Regards,
Junior Dominguez
Telerik