I follow the Bertrand Le Roy guide to migrate OrchardCMS to the document repository (pre-release branch 1.x)
http://weblogs.asp.net/bleroy/archive/2013/11/04/the-shift-how-orchard-painlessly-shifted-to-document-storage-and-how-it-ll-affect-you. aspx
Here are some excerpts from my sample code in an attempt to mix records and non-decompression properties in ContentPart.
Migration
public int Create() {
SchemaBuilder.CreateTable("CustomerPartRecord",
table => table
.ContentPartRecord()
.Column<string>("Name")
);
ContentDefinitionManager.AlterPartDefinition("CustomerPart", builder => builder
.Attachable());
ContentDefinitionManager.AlterTypeDefinition("Customer",
type => type
.WithPart("CommonPart")
.WithPart("Title")
.WithPart("CustomerPart")
.Creatable());
return 1;
}
ContentPartRecord
public class CustomerPartRecord : ContentPartRecord {
public virtual string Name { get; set; }
public virtual string Phone { get; set; }
public virtual string Email { get; set; }
}
Contentpart
public class CustomerPart : ContentPart<CustomerPartRecord>
{
public string Name
{
get { return Record.Name; }
set { Record.Name = value; }
}
public string Phone
{
get { return this.Retrieve(x => x.Phone); }
set { this.Store(x => x.Phone, value); }
}
public string Email
{
get { return this.Retrieve(x => x.Email); }
set { this.Store(x => x.Email, value); }
}
}
Throws the following error when trying to add a new record
could not insert: [Customers.Models.CustomerPartRecord#28][SQL: INSERT INTO Teknorix_Customers_CustomerPartRecord (Name, Phone, Email, Id) VALUES (?, ?, ?, ?)] ---> System.Data.SqlServerCe.SqlCeException: The column name is not valid. [ Node name (if any) = ,Column name = Phone ]
This works absolutely fine if I add the phone and email column to the database. but then it writes data in 2 places. in xml it will only insert phone and email fields. and in the table it will insert the whole record.
, Retrieve() this.Retrieve(), .. .....
XML- . ?