Sitefinity CMS

Working with Data in Sitefinity Send comments on this topic.
See Also
Developing with Sitefinity > Data Access > Working with Data in Sitefinity

Glossary Item Box

This topic provides information on the options to work with Data in Sitefinity.

 

Sitefinity is an extremely flexible application when it comes to working with data. It is possible not only to use any kind of data storage for the custom functionality (such as custom modules), but also to use any kind of data storage for the built-in functionalities such as blogs, pages, news, events, and so on. Sitefinity uses the Provider Model pattern which allows implementing a new provider for any part of Sitefinity.

 

Standard Way of Working with Data in Sitefinity

By default, Sitefinity uses Nolics.NET O/RM for all data-related work. Nolics.NET is an O/RM (object-relational mapping) which provides some very powerful features out of the box. So, for example, Nolics.NET is capable to work interchangeably with SQL Server, SQL Server Express, Oracle and MySql with no extra coding needed. In addition to this, Nolics.NET supports forward engineering which means that it will create all the necessary tables and stored procedures  based on your persistence classes. Nolics.NET will also upgrade the database automatically, in case of changes to persistence classes.

To learn more about Nolics.NET you can visit www.nolics.net. More detailed instructions for working with Nolics.NET in Sitefinity could be found in the section "Nolics.NET Examples".

Sitefinity includes an OEM license for the Nolics.NET engine and designers. This means that you are licensed to use Nolics in building custom Sitefinity components such as custom modules.

 

Implementing Custom Data Access Layer

Since Sitefinity is built on top of the Provider Model pattern, implementing any kind of data layer is not difficult. Let us assume that we want to implement LINQ to SQL data access layer for Blogs module, instead of the built-in Nolics.NET access layer. This is a very simple task since all one needs to do is implement a new provider for the Blogs module and override methods such as GetContent, GetBlogs, CreateBlog and so on. In the overridden implementations one would use LINQ to SQL to perform data operations.

The new Blogs provider must inherit the Telerik.Cms.Engine.Data.DefaultProvider base class and implement the IBlogProvider interface.

It is even easier when it comes to new functionalities. For example, when implementing a new module, you’d like the data for this module to be stored in XML file. The best approach is to follow the Provider Pattern model. Instead of using Nolics.NET when it comes to working with data, you could be using classes from the System.Xml namespace such as XmlDocument, XmlTextReader and so on.


The conclusion is: Nolics.NET is just one way of working with data, and not the only way. The best way ultimately depends on the functionality you are developing.

 

Do You Need Custom Data Layer?

While we suggest implementing 3-layered architecture for all modules, this is not a requirement imposed by Sitefinity. For example, you can develop a simple user control and use SqlDataSource control to interact directly with SQL Server database. SqlDataSource or any other way of accessing data is supported when building modules as well. Therefore, the three-layered architecture is not a requirement but merely a recommendation.

See Also