Extend Sitefinity CMS data model: Create the custom type class
After you reference the required assemblies, you implement the custom type class. The custom type class is used to persist the information to the database. Such classes are also called model classes. Depending on the design, you can create more than one model class.
To be more consistent with Sitefinity's architecture, the CustomType class implements the IDataItem interface. Inside the CustomTypesclass you add the properties that are persisted to the database.
- In Visual Studio, open the context menu of the project and click Add » Class.
- Name the class file
CustomType.cs - Make the
CustomTypeclass implement theIDataIteminterface. - Define the
ApplicationName,Id,LastModified,Provider, andTransactionproperties from theIDataIteminterface. - Define any additional properties that you want to persist to to database.
- Create a constructor that sets the values for the
ApplicationNameandId.
Use the following code sample:
C#
using System;
using Telerik.Sitefinity.Model;
namespace SitefinityWebApp
{
public class CustomType : IDataItem
{
public Guid Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
public object Transaction
{
get
{
return this.transaction;
}
set
{
this.transaction = value;
}
}
public object Provider
{
get
{
return this.provider;
}
set
{
this.provider = value;
}
}
public DateTime LastModified
{
get
{
return this.lastModified;
}
set
{
this.lastModified = value;
}
}
public string ApplicationName
{
get
{
return this.appName;
}
set
{
this.appName = value;
}
}
private Guid id;
private string appName;
private object transaction;
private object provider;
private DateTime lastModified;
public string Title
{
get
{
return this.title;
}
set
{
this.title = value;
}
}
private string title;
public CustomType()
{
}
public CustomType(string applicationName, Guid id)
{
this.id = id;
this.appName = applicationName;
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.