Custom content part with its own body element

Topics: Customizing Orchard, Troubleshooting, Writing modules
May 5, 2011 at 8:14 PM

Hi people,

I wrote a custom content part and for the most part it works fine. I am going to add its own body content instead of the original body.
So I added a new element into the part and record. Example:

        [Required]
        public string Data
        {
            get { return Record.Data; }
            set { Record.Data= value; }
        }
 
So I wrote the update code to add a column with DbType.String and used the TinyMCE textarea.
The editor page shows up correctly with the TinyMCE textarea, but if I enter a huge chunk of html, I get this error.

 

The data was truncated while converting from one data type to another. [ Name of function(if known) = ]

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlServerCe.SqlCeException: The data was truncated while converting from one data type to another. [ Name of function(if known) = ]

 

Any one can help me figure out why that happens? A short text works fine though...


Coordinator
May 5, 2011 at 8:24 PM

Add the StringLengthMax attribute to the Record's property Data. Then automatic data migration will handle it. Or if you have already generated the migration, add c => c.Unlimited() on this specific column.

May 5, 2011 at 8:49 PM

Thanks for the prompt response, i added the attribute to the property and dropColumn AddColumn in the migration.

Everything is working as expected.. :)