mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
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:
@@ -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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/Orchard/Data/Conventions/StringLengthConvention.cs
Normal file
17
src/Orchard/Data/Conventions/StringLengthConvention.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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" />
|
||||||
|
Reference in New Issue
Block a user