Tales from the Evil Empire

Bertrand Le Roy's blog

  • Making MiniProfiler work in the Orchard dashboard

    MiniProfiler is a wonderful module. It’s especially good at showing you the select n+1 problems in your Orchard applications. For some reason that is not entirely clear to me, however, it is only active on the front-end. If you have to debug a performance issue in the dashboard, you’re out of luck. Fortunately, the limitation is entirely arbitrary, easy to find, and easy to remove.

    Read more...

  • A better way to play with HQL in Orchard

    In previous posts, I’ve shown how to query Orchard with straight HQL. However, I haven’t provided a good environment to run and debug these queries so far, because I didn’t have one. As a matter of facts, my method to build new queries has consisted in building queries from the projection module, putting a breakpoint at the end of the “DefaultHqlQuery.ToHql” method, and previewing the query in order to steal the query string built by the projection module. To debug, I’ve put the code in custom controller actions, and debugged the exceptions from VS. Not super-convenient.

    Read more...

  • Querying Orchard fields with HQL

    Before projections, the official word on fields was that they weren’t for querying (they are stored in an XML blob on the content item record). Projections enabled field querying for the first time, through special tables that index field contents: Orchard_Projections_DecimalFieldIndexRecord, Orchard_Projections_DoubleFieldIndexRecord, Orchard_Projections_IntegerFieldIndexRecord, and Orchard_Projections_StringFieldIndexRecord. Each table is specialized for one underlying value type.An indexing table has columns for property names and values

    Read more...

  • A storm of fail

    It’s OK to not know something. It really is, if you’re willing to admit it, and have a reasonably accurate idea about your own level of competence. Unfortunately, thanks to the Dunning-Kruger effect, we’re all better than average drivers, parents, and… security experts. Through the excellent @InfoSecInsanity, I got pointed to a veritable (and unfortunately, involuntary) repository of ways you can screw up your web site’s security. I don’t want to pick too much on the author, as as far as I know, he’s well-intentioned, but he should really retract his post, as well as any other post he wrote about security, and take a few courses. He might also want to stop calling himself an”expert” about topics on which he has clearly no expertise.  Writing crappy code is one thing. Propagating dangerous code through blog posts, that hundreds of clueless people will copy into their own applications, is another.

    Read more...

  • Getting Orchard content items out of HQL

    I the two previous posts (here and here), I’ve showed how to build HQL queries against the Orchard database. Once you’ve built the query, you’ll want to get results, often in the form of fully-built content items. In lots of cases, you’ll want to paginate the results, for which you’ll need a total count, and detailed results for only the current page. This post will show you how to do all these things.

    Read more...

  • Joining Orchard part records in HQL

    In yesterday’s post, I showed the basics of HQL querying in Orchard. It is by far the most flexible way to  query Orchard’s database, but one thing I didn’t show is how this works in relation to Orchard’s content type system. Querying over records is nice, but if those records are part records, you need to be really careful and check that they correspond to a real content item, that his content hasn’t been archived, and that its publication state is what you need it to be. In order to do that, you’ll have to join with ContentItemRecord and ContentItemVersionRecord. But how do you express joins in HQL in a way that works with Orchard records?

    Read more...

  • Querying Orchard in HQL

    Orchard has two APIs on IContentManager to query content items: Query, and HqlQuery. Query is the older API, but it’s also the simplest. It’s great when you want to perform a simple query such as “get all content items with part TitlePart where the title begins with A”. HqlQuery is a little more advanced, closer to nHibernate APIs, and allows for more complex queries. It was added to build the dynamic queries necessary for Projections. It is still, however, designed around the Orchard content type system, which makes it inadequate for queries that don’t trivially map to content items and parts.

    Read more...

  • A blogging experiment

    I consider blogging to be a very efficient way to help the community while promoting my own personal brand (which is important not for my oversized ego, but because I’m an independent consultant, and more visibility means more and better contracts). Many successful bloggers blog often, sometimes several times a day. I’ve never been able to sustain a frequency of more than a post per week myself so far, but for about a week, I’ve been trying something different. I’ve decided that I would write something every day, whether it’s a post for one of my blogs, a page for a book, training material, or some personal notes. The idea is to make writing a part of my everyday routine.

    Read more...

  • Speeding up pages with lots of media content items

    For a few versions now, Orchard has been treating media (images, videos, etc.) as content items. There is a special kind of field, MediaLibraryPickerField, that enables you to add images, or collections of images, to any content type. For example, on the Nwazet web site, I’ve added a “Image Gallery” field to the product content type:

    Read more...