New Content-Language HTTP header feature, LINQ to DB - This week in Orchard (21/09/2021)

gabor.domonkos

Add Content-Language HTTP header feature, new Health Check option, LINQ to DB demo, and many more coming this week! Do you want to know more? Then don't forget to check out our current post!

Orchard Core updates

Add Content-Language HTTP header feature

While the Accept-Language header is useful for the request, Content-Language is very useful too for the response, there's no support for this yet. But that was the past! Now if you head to the admin UI of your Orchard Core and navigate to Configuration -> Features, you will find a new feature called Content-Language header that adds the Content-Language HTTP header, which describes the language(s) intended for the audience.

The ContentLanguageHeaderSetup class

Let's enable this module and see it in action! In this case, we just open up the DevTools of Google Chrome, click on the Network tab and check the content of the Headers tab after loading a page with a content item. In our case, we opened the home page of the tenant called blog1. As you can see, the Content-Language header is there containing the language of the given content, which is en-US in our case.

The new conent-lanugage header

Add Health Check options

The option here is to be able to change the default URL of the Health Check. The health/live is the default one provided by ASP.NET. If you enable the Health Check feature and navigate to an URL like https://localhost:44300/health/live you will see the status of your site. And now, you can easily change the value of this URL by just updating the value of the URL of the OrchardCore_HealthChecks section in the appsettings.json file.

Health Check URL

Allow custom editors for Bag/Flow/WidgetsList Parts

If you checked the drivers of the BagPart, FlowPart, or the WidgetsListPart, you would notice that these drivers were using hard-coded shapes, and now you can have custom editors based on the editor name, and you can select it. The default editor for these drivers is called Standard.

Custom editors for Bag Part and Flow Part

Demos

LINQ to DB - Lombiq Helpful Libraries for Orchard Core

The LINQ to DB subproject is part of our Helpful Libraries project that contains various libraries that can be handy when developing for Orchard Core CMS, to be used from your Orchard modules. The use-case is that sometimes you just have to go to SQL. Although we have YesSql, we have all the abstractions, but of course, the SQL connection is still there if you want to go low level. Sometimes you have to write some funky query there, or otherwise, you just want to store something in the database which is not a content item, not necessarily an entity, just a simple table with some simple rows. And in that case, you may not want to write like SQL queries as strings. But still, you don't want to use a full-blown ORM like Entity Framework because that would be a bit of an overkill for use-cases where you don't need a full-blown application built on it. And for such cases, there is a library called LINQ to DB, which is a third-party library. LINQ to DB is the fastest LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database.

LINQ to DB readme

What we have implemented in our project is that by just hooking into ISession (which is the standard YesSql ISession), you will get to write queries like this:

Samples to use LINQ to DB

There is a helper method, and in there you can pretty much write LINQ against tables. In this case, we are using the AutoroutePartIndex as the example, and as you can see it's LINQ as usual but since you are wrapped into this LingQueryAsync, the inside of it is executed as SQL directly.

And as always, if you would like to know more about the LINQ to DB subproject, head to YouTube for a recording!

News from the community

A new website using Orchard Core: Planters Products Inc

Planters Products, Inc. was established in 1963 as one of the leading Agricultural Chemical Companies in the Philippines. In 1970 it was purchased by the Sugar Producers Cooperative Marketing Association, the country's largest cooperative of sugar planters, and renamed Planters Products, Incorporated (PPI). Check out this brand new Orchard Core site here!

Planters Products Inc. website

If you are interested in more websites using Orchard and Orchard Core, don't forget to visit Show Orchard. Show Orchard is a website for showing representative Orchard CMS (and now Orchard Core) websites all around the internet. It was started by Ryan Drew Burnett, but since he doesn't work with Orchard anymore, as announced earlier it is now maintained by our team at Lombiq Technologies.

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 224 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!