#18641: Fixing SqlCe limit for binary data

Work Item: 18641

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-05-01 12:30:06 -07:00
parent 743952b418
commit 5750f68b19
3 changed files with 13 additions and 5 deletions
+4 -2
View File
@@ -17,7 +17,7 @@ namespace Orchard.Tests.Data {
ProviderUtilities.RunWithSqlCe(recordDescriptors, ProviderUtilities.RunWithSqlCe(recordDescriptors,
sessionFactory => { sessionFactory => {
var session = sessionFactory.OpenSession(); var session = sessionFactory.OpenSession();
var foo = new BigRecord { Body = new String('x', 10000) }; var foo = new BigRecord { Body = new String('x', 10000), Banner = new byte[10000]};
session.Save(foo); session.Save(foo);
session.Flush(); session.Flush();
session.Close(); session.Close();
@@ -28,6 +28,7 @@ namespace Orchard.Tests.Data {
Assert.That(foo, Is.Not.Null); Assert.That(foo, Is.Not.Null);
Assert.That(foo.Body, Is.EqualTo(new String('x', 10000))); Assert.That(foo.Body, Is.EqualTo(new String('x', 10000)));
Assert.That(foo.Banner.Length, Is.EqualTo(10000));
}); });
} }
@@ -42,7 +43,7 @@ namespace Orchard.Tests.Data {
ProviderUtilities.RunWithSqlServer(recordDescriptors, ProviderUtilities.RunWithSqlServer(recordDescriptors,
sessionFactory => { sessionFactory => {
var session = sessionFactory.OpenSession(); var session = sessionFactory.OpenSession();
var foo = new BigRecord { Body = new String('x', 10000) }; var foo = new BigRecord { Body = new String('x', 10000), Banner = new byte[10000] };
session.Save(foo); session.Save(foo);
session.Flush(); session.Flush();
session.Close(); session.Close();
@@ -53,6 +54,7 @@ namespace Orchard.Tests.Data {
Assert.That(foo, Is.Not.Null); Assert.That(foo, Is.Not.Null);
Assert.That(foo.Body, Is.EqualTo(new String('x', 10000))); Assert.That(foo.Body, Is.EqualTo(new String('x', 10000)));
Assert.That(foo.Banner.Length, Is.EqualTo(10000));
}); });
} }
+3
View File
@@ -5,5 +5,8 @@ namespace Orchard.Tests.Records {
public virtual int Id { get; set; } public virtual int Id { get; set; }
[StringLengthMax] [StringLengthMax]
public virtual string Body { get; set; } public virtual string Body { get; set; }
[StringLengthMax]
public virtual byte[] Banner { get; set; }
} }
} }
@@ -83,6 +83,12 @@ namespace Orchard.Data.Providers {
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) {
base.InitializeParameter(dbParam, name, sqlType); base.InitializeParameter(dbParam, name, sqlType);
if(sqlType.DbType == DbType.Binary) {
_dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null);
return;
}
if ( sqlType.Length <= 4000 ) { if ( sqlType.Length <= 4000 ) {
return; return;
} }
@@ -94,9 +100,6 @@ namespace Orchard.Data.Providers {
case DbType.AnsiString: case DbType.AnsiString:
_dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Text, null); _dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Text, null);
break; break;
case DbType.Byte:
_dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null);
break;
} }
} }
} }