How to write straight SQL to retrieve content records with where on some fields?

Topics: Administration, Core, General, Writing modules
May 15, 2014 at 5:05 PM
Edited May 15, 2014 at 6:24 PM
I am building a website that has dynamic content.

Because of the customer requirement, the website CANNOT built be any CMS, but I still needs a data entry tool for data records. I am hoping to use Orchard purely as a data entry tool, not mentioning that Orchard comes with the admin interface security, publish/unpublish, etc., which are nice to have.

The content record has the following fields:

date 1
date 2

I created the content type in Orchard and entered a few records. Now I need to write straight SQL to get content records out based on conditions on date 1 and date 2 fields. After examining Orchards's all tables, I am unable to figure out how to get records out with a single SQL statement.

Any direct or indirect approach?

The reason that I am hoping to use Orchard (not Drupal, etc.) as the data entry tool is that I hope to persuade the customer to rebuild the website's with Orchard too in the future. At this moment, the website is built with ASP.NET and Razor.

Any input is really appreciated.

May 15, 2014 at 6:48 PM
May 15, 2014 at 8:34 PM
Edited May 15, 2014 at 8:40 PM

Thanks soooooooooo much for the above post. I installed Orchard 1.8 and within it I created the content type with two additional date fields. I entered a few records. I did not do anything special beyond that. However, I am unable to see tables similar to Orchard_Autoroute_AutoroutePartRecord. Do I need to install any additional modules for this? I need to be able to where and sort on the date fields.

I don't do anything like "When a record class inherits from ContentPartRecord, it's Id will have the same value as ContentItemRecord.Id. ....". If this is a must, any pointer on this?

A bit more: I went to, entered the above content plus my first name and recapcha number, and I got the following error:

Server Error in '/' Application.
attempted to assign id from null one-to-one property: ContentItemRecord