Correcting text field lengths in sql server

Convention adds support for StringLengthAttribute
Adds StringLengthMax attribute to hide arbitrarily large number
Increate Routable.Title length to nvarchar(1024) and Body.Text length to nvarchar(max)
This commit is contained in:
Louis DeJardin
2010-02-22 13:17:11 -08:00
parent c555f05404
commit c7e95e31ea
4 changed files with 25 additions and 1 deletions

View File

@@ -1,8 +1,11 @@
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Core.Common.Records { namespace Orchard.Core.Common.Records {
public class BodyRecord : ContentPartVersionRecord { public class BodyRecord : ContentPartVersionRecord {
[StringLengthMax]
public virtual string Text { get; set; } public virtual string Text { get; set; }
public virtual string Format { get; set; } public virtual string Format { get; set; }
} }
} }

View File

@@ -1,8 +1,11 @@
using Orchard.ContentManagement.Records; using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Records { namespace Orchard.Core.Common.Records {
public class RoutableRecord : ContentPartVersionRecord { public class RoutableRecord : ContentPartVersionRecord {
[StringLength(1024)]
public virtual string Title { get; set; } public virtual string Title { get; set; }
public virtual string Slug { get; set; } public virtual string Slug { get; set; }
} }
} }

View File

@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;
namespace Orchard.Data.Conventions {
public class StringLengthMaxAttribute : StringLengthAttribute {
public StringLengthMaxAttribute() : base(10000) {
// 10000 is an arbetrary number large enough to be in the nvarchar(max) range
}
}
public class StringLengthConvention : AttributePropertyConvention<StringLengthAttribute> {
protected override void Apply(StringLengthAttribute attribute, IPropertyInstance instance) {
instance.Length(attribute.MaximumLength);
}
}
}

View File

@@ -138,6 +138,7 @@
<Compile Include="Data\Builders\ISessionFactoryBuilder.cs" /> <Compile Include="Data\Builders\ISessionFactoryBuilder.cs" />
<Compile Include="Data\Builders\SQLiteBuilder.cs" /> <Compile Include="Data\Builders\SQLiteBuilder.cs" />
<Compile Include="Data\Builders\SqlServerBuilder.cs" /> <Compile Include="Data\Builders\SqlServerBuilder.cs" />
<Compile Include="Data\Conventions\StringLengthConvention.cs" />
<Compile Include="Data\SessionFactoryHolder.cs" /> <Compile Include="Data\SessionFactoryHolder.cs" />
<Compile Include="Environment\Configuration\AppDataFolder.cs" /> <Compile Include="Environment\Configuration\AppDataFolder.cs" />
<Compile Include="Environment\Configuration\ShellSettingsLoader.cs" /> <Compile Include="Environment\Configuration\ShellSettingsLoader.cs" />