String Unlimited still limited to 4000 characters?

Topics: Core, Customizing Orchard, Writing modules
Aug 19, 2013 at 2:19 PM
Edited Aug 19, 2013 at 2:22 PM
Here is the piece in my migration file that creates the table:
            // Creating table SessionInformationRecord
            SchemaBuilder.CreateTable("SessionInformationRecord", table => table
                .Column("Id", DbType.Int32, column => column.PrimaryKey().Identity())
                .Column("TrackInformationRecord_Id", DbType.Int32)
                .Column("Title", DbType.String, col => col.Unlimited())
                .Column("Description", DbType.String, col => col.Unlimited())
                .Column("StartDate", DbType.DateTime)
                .Column("EndDate", DbType.DateTime)
                .Column("HasEvaluation", DbType.Boolean)
                .Column("IsDeleted", DbType.Boolean)
            );
The Title and Description are supposed to be unlimited Strings. However, When I enter content for those fields that are beyond 4000 characters, I get this error:
{"@p1 : String truncation: max=4000, len=21588, value=''."}
Any other way to get around this? Or is 4000 characters the max for a String?
Developer
Aug 19, 2013 at 10:10 PM
Nope, it's just NH default behavior. Put [StringLengthMax] attribute on Title and Description properties and you're set.
Aug 20, 2013 at 5:00 PM
Thanks for that @pszmyd! Just to clarify, I put the [StringLengthMax] attribute into the class in the model, right? What do I need to import to use the attribute? I tried to put it in but it can't find the attribute, it only recognizes [StringLength].

Here are my model classes:
    public class TrackInformationRecord
    {
        public virtual int Id { get; set; }
        public virtual int TrackPartId { get; set; }
        [StringLengthMax]
        public virtual string Title { get; set; }
        [StringLengthMax]
        public virtual string Description { get; set; }
        public virtual bool IsDeleted { get; set; }

        public virtual IList<SessionInformationRecord> Sessions { get; set; }
    }

    public class SessionInformationRecord
    {
        public virtual TrackInformationRecord TrackInformationRecord { get; set; }

        public virtual int Id { get; set; }
        [StringLengthMax]
        public virtual string Title { get; set; }
        [StringLengthMax]
        public virtual string Description { get; set; }
        public virtual DateTime StartDate { get; set; }
        public virtual DateTime EndDate { get; set; }
        public virtual bool HasEvaluation { get; set; }
        public virtual bool IsDeleted { get; set; }
     }
Developer
Aug 20, 2013 at 5:16 PM
Edited Aug 20, 2013 at 5:16 PM