IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
After you Testimonials module: Create the data model class, you need to create the specific metadata source. To do so:
using
System.Collections.Generic;
Telerik.OpenAccess.Metadata.Fluent;
public
class
TestimonialsFluentMetaDataSource : FluentMetadataSource
{
}
private
MappingConfiguration<Testimonial> MapTestimonialsTable()
// map to table
var tableMapping =
new
MappingConfiguration<Testimonial>();
tableMapping.MapType().ToTable(
"sf_testimonials"
);
// map properties
tableMapping.HasProperty(t => t.Id).IsIdentity(Telerik.OpenAccess.Metadata.KeyGenerator.Guid);
tableMapping.HasProperty(t => t.Name).HasLength(255).IsNotNullable();
tableMapping.HasProperty(t => t.Summary).HasLength(255).IsNotNullable();
tableMapping.HasProperty(t => t.Text).HasColumnType(
"varchar(max)"
tableMapping.HasProperty(t => t.Rating).IsNotNullable();
tableMapping.HasProperty(t => t.DatePosted).IsNotNullable();
tableMapping.HasProperty(t => t.Published).IsNotNullable();
tableMapping.HasProperty(t => t.UrlName).IsNotNullable();
return
tableMapping;
protected
override
IList<MappingConfiguration> PrepareMapping()
var mappings =
List<MappingConfiguration>();
var testimonialMapping = MapTestimonialsTable();
mappings.Add(testimonialMapping);
mappings;
You inherit from FluentMetadataSource and reuse the functionality in the method. In addition, you override the PrepareMapping method. The MapTestimonialsTable method maps the testimonial class to a database table.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important