asp.netorchardcmsdocument-storage

Orchard Document Storage Query


I'm trying to create an IContentQuery based on the properties set in a custom part created using document storage, but I can't seem to find any good examples on how to do this. It is very simple to do it if I set up a ContantPartRecord, but I'd like to start using the new document storage functionality.

The current query I am trying to make is equivalent to the query I would make with a ContentPartRecord like this:

var activities = _contentManager.Query<ActivityPart, ActivityPartRecord>()
                                        .Where(x => (startDate <= x.DateTimeStart && x.DateTimeStart <= endDate) ||
                                                    (startDate <= x.DateTimeEnd && x.DateTimeEnd <= endDate)).OrderBy(x => x.DateTimeStart).List();

Is it possible to do this using document storage?

Thanks in advance.


Solution

  • Why do you want to use document storage for this? This is precisely a case where you shouldn't, for exactly the reason that you won't be able to query on your property, except if you go through the same hoops as the Projection module, which is creating index tables, which is a lot more complicated than just using a record. Conclusion: use a record as usual, not document storage.