Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed byte[] issue

  • Loading branch information...
commit 584765e37e314c55d7cb57244c06d26c838d34f6 1 parent bce850d
@brainless83 authored
View
1  src/ServiceStack.OrmLite.MySql.Tests/ServiceStack.OrmLite.MySql.Tests.csproj
@@ -101,6 +101,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShippersExample.cs" />
<Compile Include="SqlMapperTests.cs" />
+ <Compile Include="TypeWithByteArrayFieldTests.cs" />
<Compile Include="UseCase\CustomerOrdersUseCase.cs" />
<Compile Include="UseCase\SimpleUseCase.cs" />
<Compile Include="OrmLiteGetScalarTests.cs" />
View
31 src/ServiceStack.OrmLite.MySql.Tests/TypeWithByteArrayFieldTests.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+namespace ServiceStack.OrmLite.MySql.Tests
+{
+ public class TypeWithByteArrayFieldTests : OrmLiteTestBase
+ {
+ [Test]
+ public void CanInsertAndSelectByteArray()
+ {
+ var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
+
+ using (var db = ConnectionString.OpenDbConnection())
+ {
+ db.CreateTable<TypeWithByteArrayField>(true);
+
+ db.Save(orig);
+
+ var target = db.GetById<TypeWithByteArrayField>(orig.Id);
+
+ Assert.AreEqual(orig.Id, target.Id);
+ Assert.AreEqual(orig.Content, target.Content);
+ }
+ }
+ }
+
+ class TypeWithByteArrayField
+ {
+ public int Id { get; set; }
+ public byte[] Content { get; set; }
+ }
+}
View
210 src/ServiceStack.OrmLite.MySql/MySqlDialectProvider.cs
@@ -1,19 +1,19 @@
using System;
using System.Collections.Generic;
-using System.Data;
+using System.Data;
using System.Text;
-using MySql.Data.MySqlClient;
-using ServiceStack.Common.Extensions;
-using ServiceStack.OrmLite.MySql.DataAnnotations;
-
+using MySql.Data.MySqlClient;
+using ServiceStack.Common.Extensions;
+using ServiceStack.OrmLite.MySql.DataAnnotations;
+
namespace ServiceStack.OrmLite.MySql
-{
+{
public class MySqlDialectProvider : OrmLiteDialectProviderBase<MySqlDialectProvider>
{
- public static MySqlDialectProvider Instance = new MySqlDialectProvider();
-
- private const string TextColumnDefinition = "TEXT";
-
+ public static MySqlDialectProvider Instance = new MySqlDialectProvider();
+
+ private const string TextColumnDefinition = "TEXT";
+
private MySqlDialectProvider()
{
base.AutoIncrementDefinition = "AUTO_INCREMENT";
@@ -21,15 +21,15 @@ private MySqlDialectProvider()
base.BoolColumnDefinition = "tinyint(1)";
base.TimeColumnDefinition = "time";
base.DecimalColumnDefinition = "decimal(38,6)";
- base.GuidColumnDefinition = "char(32)";
+ base.GuidColumnDefinition = "char(32)";
base.DefaultStringLength = 255;
- base.InitColumnTypeMap();
- base.DefaultValueFormat = " DEFAULT '{0}'";
+ base.InitColumnTypeMap();
+ base.DefaultValueFormat = " DEFAULT '{0}'";
}
-
- public override string GetQuotedParam(string paramValue)
- {
- return "'" + paramValue.Replace("\\", "\\\\").Replace("'", @"\'") + "'";
+
+ public override string GetQuotedParam(string paramValue)
+ {
+ return "'" + paramValue.Replace("\\", "\\\\").Replace("'", @"\'") + "'";
}
public override IDbConnection CreateConnection(string connectionString, Dictionary<string, string> options)
@@ -43,12 +43,12 @@ public override string GetQuotedValue(object value, Type fieldType)
if (fieldType == typeof(DateTime))
{
- var dateValue = (DateTime)value;
+ var dateValue = (DateTime)value;
/*
* ms not contained in format. MySql ignores ms part anyway
*
* for more details see: http://dev.mysql.com/doc/refman/5.1/en/datetime.html
- */
+ */
const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
return base.GetQuotedValue(dateValue.ToString(dateTimeFormat), typeof(string));
@@ -59,6 +59,11 @@ public override string GetQuotedValue(object value, Type fieldType)
return base.GetQuotedValue(guidValue.ToString("N"), typeof(string));
}
+ if (fieldType == typeof(byte[]))
+ {
+ return "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
+ }
+
return base.GetQuotedValue(value, fieldType);
}
@@ -66,34 +71,37 @@ public override object ConvertDbValue(object value, Type type)
{
if (value == null || value is DBNull) return null;
- if (type == typeof(bool))
- {
- return
- value is bool
- ? value
+ if (type == typeof(bool))
+ {
+ return
+ value is bool
+ ? value
: (int.Parse(value.ToString()) != 0); //backward compatibility (prev version mapped bool as bit(1))
}
+ if (type == typeof(byte[]))
+ return value;
+
return base.ConvertDbValue(value, type);
}
public override string GetQuotedTableName(ModelDefinition modelDef)
{
return string.Format("`{0}`", NamingStrategy.GetTableName(modelDef.ModelName));
- }
+ }
public override string GetQuotedTableName(string tableName)
{
return string.Format("`{0}`", NamingStrategy.GetTableName(tableName));
}
-
- public override string GetQuotedColumnName(string columnName)
- {
- return string.Format("`{0}`", NamingStrategy.GetColumnName(columnName));
+
+ public override string GetQuotedColumnName(string columnName)
+ {
+ return string.Format("`{0}`", NamingStrategy.GetColumnName(columnName));
}
public override string GetQuotedName(string name)
- {
+ {
return string.Format("`{0}`", name);
}
@@ -108,78 +116,78 @@ public override long GetLastInsertId(IDbCommand command)
public override SqlExpressionVisitor<T> ExpressionVisitor<T> ()
{
return new MySqlExpressionVisitor<T>();
- }
-
- public override bool DoesTableExist(IDbCommand dbCmd, string tableName)
- {
- //Same as SQL Server apparently?
+ }
+
+ public override bool DoesTableExist(IDbCommand dbCmd, string tableName)
+ {
+ //Same as SQL Server apparently?
var sql = ("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES " +
"WHERE TABLE_NAME = {0} AND " +
- "TABLE_SCHEMA = {1}")
- .SqlFormat(tableName, dbCmd.Connection.Database);
-
- //if (!string.IsNullOrEmpty(schemaName))
- // sql += " AND TABLE_SCHEMA = {0}".SqlFormat(schemaName);
-
- dbCmd.CommandText = sql;
- var result = dbCmd.GetLongScalar();
-
- return result > 0;
- }
-
- public override string ToCreateTableStatement(Type tableType)
- {
- var sbColumns = new StringBuilder();
- var sbConstraints = new StringBuilder();
-
- var modelDef = GetModel(tableType);
- foreach (var fieldDef in modelDef.FieldDefinitions)
- {
- if (sbColumns.Length != 0) sbColumns.Append(", \n ");
-
- sbColumns.Append(GetColumnDefinition(fieldDef));
-
- if (fieldDef.ForeignKey == null) continue;
-
- var refModelDef = GetModel(fieldDef.ForeignKey.ReferenceType);
- sbConstraints.AppendFormat(
- ", \n\n CONSTRAINT {0} FOREIGN KEY ({1}) REFERENCES {2} ({3})",
- GetQuotedName(fieldDef.ForeignKey.GetForeignKeyName(modelDef, refModelDef, NamingStrategy, fieldDef)),
- GetQuotedColumnName(fieldDef.FieldName),
- GetQuotedTableName(refModelDef),
- GetQuotedColumnName(refModelDef.PrimaryKey.FieldName));
-
- if (!string.IsNullOrEmpty(fieldDef.ForeignKey.OnDelete))
- sbConstraints.AppendFormat(" ON DELETE {0}", fieldDef.ForeignKey.OnDelete);
-
- if (!string.IsNullOrEmpty(fieldDef.ForeignKey.OnUpdate))
- sbConstraints.AppendFormat(" ON UPDATE {0}", fieldDef.ForeignKey.OnUpdate);
- }
- var sql = new StringBuilder(string.Format(
- "CREATE TABLE {0} \n(\n {1}{2} \n); \n", GetQuotedTableName(modelDef), sbColumns, sbConstraints));
-
- return sql.ToString();
- }
-
- public string GetColumnDefinition(FieldDefinition fieldDefinition)
- {
- if (fieldDefinition.PropertyInfo.FirstAttribute<TextAttribute>() != null)
- {
- var sql = new StringBuilder();
- sql.AppendFormat("{0} {1}", GetQuotedColumnName(fieldDefinition.FieldName), TextColumnDefinition);
- sql.Append(fieldDefinition.IsNullable ? " NULL" : " NOT NULL");
- return sql.ToString();
- }
-
- return base.GetColumnDefinition(
- fieldDefinition.FieldName,
- fieldDefinition.FieldType,
- fieldDefinition.IsPrimaryKey,
- fieldDefinition.AutoIncrement,
- fieldDefinition.IsNullable,
- fieldDefinition.FieldLength,
- null,
- fieldDefinition.DefaultValue);
- }
+ "TABLE_SCHEMA = {1}")
+ .SqlFormat(tableName, dbCmd.Connection.Database);
+
+ //if (!string.IsNullOrEmpty(schemaName))
+ // sql += " AND TABLE_SCHEMA = {0}".SqlFormat(schemaName);
+
+ dbCmd.CommandText = sql;
+ var result = dbCmd.GetLongScalar();
+
+ return result > 0;
+ }
+
+ public override string ToCreateTableStatement(Type tableType)
+ {
+ var sbColumns = new StringBuilder();
+ var sbConstraints = new StringBuilder();
+
+ var modelDef = GetModel(tableType);
+ foreach (var fieldDef in modelDef.FieldDefinitions)
+ {
+ if (sbColumns.Length != 0) sbColumns.Append(", \n ");
+
+ sbColumns.Append(GetColumnDefinition(fieldDef));
+
+ if (fieldDef.ForeignKey == null) continue;
+
+ var refModelDef = GetModel(fieldDef.ForeignKey.ReferenceType);
+ sbConstraints.AppendFormat(
+ ", \n\n CONSTRAINT {0} FOREIGN KEY ({1}) REFERENCES {2} ({3})",
+ GetQuotedName(fieldDef.ForeignKey.GetForeignKeyName(modelDef, refModelDef, NamingStrategy, fieldDef)),
+ GetQuotedColumnName(fieldDef.FieldName),
+ GetQuotedTableName(refModelDef),
+ GetQuotedColumnName(refModelDef.PrimaryKey.FieldName));
+
+ if (!string.IsNullOrEmpty(fieldDef.ForeignKey.OnDelete))
+ sbConstraints.AppendFormat(" ON DELETE {0}", fieldDef.ForeignKey.OnDelete);
+
+ if (!string.IsNullOrEmpty(fieldDef.ForeignKey.OnUpdate))
+ sbConstraints.AppendFormat(" ON UPDATE {0}", fieldDef.ForeignKey.OnUpdate);
+ }
+ var sql = new StringBuilder(string.Format(
+ "CREATE TABLE {0} \n(\n {1}{2} \n); \n", GetQuotedTableName(modelDef), sbColumns, sbConstraints));
+
+ return sql.ToString();
+ }
+
+ public string GetColumnDefinition(FieldDefinition fieldDefinition)
+ {
+ if (fieldDefinition.PropertyInfo.FirstAttribute<TextAttribute>() != null)
+ {
+ var sql = new StringBuilder();
+ sql.AppendFormat("{0} {1}", GetQuotedColumnName(fieldDefinition.FieldName), TextColumnDefinition);
+ sql.Append(fieldDefinition.IsNullable ? " NULL" : " NOT NULL");
+ return sql.ToString();
+ }
+
+ return base.GetColumnDefinition(
+ fieldDefinition.FieldName,
+ fieldDefinition.FieldType,
+ fieldDefinition.IsPrimaryKey,
+ fieldDefinition.AutoIncrement,
+ fieldDefinition.IsNullable,
+ fieldDefinition.FieldLength,
+ null,
+ fieldDefinition.DefaultValue);
+ }
}
}
View
1  src/ServiceStack.OrmLite.PostgreSQL.Tests/ServiceStack.OrmLite.PostgreSQL.Tests.csproj
@@ -90,6 +90,7 @@
<Compile Include="OrmLiteTestBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OrmLiteGetScalarTests.cs" />
+ <Compile Include="TypeWithByteArrayFieldTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
View
32 src/ServiceStack.OrmLite.PostgreSQL.Tests/TypeWithByteArrayFieldTests.cs
@@ -0,0 +1,32 @@
+using NUnit.Framework;
+using ServiceStack.OrmLite.Tests;
+
+namespace ServiceStack.OrmLite.PostgreSQL.Tests
+{
+ public class TypeWithByteArrayFieldTests : OrmLiteTestBase
+ {
+ [Test]
+ public void CanInsertAndSelectByteArray()
+ {
+ var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
+
+ using (var db = ConnectionString.OpenDbConnection())
+ {
+ db.CreateTable<TypeWithByteArrayField>(true);
+
+ db.Save(orig);
+
+ var target = db.GetById<TypeWithByteArrayField>(orig.Id);
+
+ Assert.AreEqual(orig.Id, target.Id);
+ Assert.AreEqual(orig.Content, target.Content);
+ }
+ }
+ }
+
+ class TypeWithByteArrayField
+ {
+ public int Id { get; set; }
+ public byte[] Content { get; set; }
+ }
+}
View
54 src/ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs
@@ -27,11 +27,11 @@ public SqlServerOrmLiteDialectProvider()
base.InitColumnTypeMap();
}
- public override string GetQuotedParam(string paramValue)
- {
- return (UseUnicode ? "N'" : "'") + paramValue.Replace("'", "''") + "'";
- }
-
+ public override string GetQuotedParam(string paramValue)
+ {
+ return (UseUnicode ? "N'" : "'") + paramValue.Replace("'", "''") + "'";
+ }
+
public override IDbConnection CreateConnection(string connectionString, Dictionary<string, string> options)
{
var isFullConnectionString = connectionString.Contains(";");
@@ -98,6 +98,9 @@ public override object ConvertDbValue(object value, Type type)
return dateTimeValue - timeSpanOffset;
}
+ if (type == typeof(byte[]))
+ return value;
+
return base.ConvertDbValue(value, type);
}
catch (Exception ex)
@@ -106,7 +109,7 @@ public override object ConvertDbValue(object value, Type type)
}
}
-
+
public override string GetQuotedValue(object value, Type fieldType)
{
if (value == null) return "NULL";
@@ -128,8 +131,9 @@ public override string GetQuotedValue(object value, Type fieldType)
return base.GetQuotedValue(boolValue ? 1 : 0, typeof(int));
}
if(fieldType == typeof(string)) {
- return GetQuotedParam(value.ToString());
+ return GetQuotedParam(value.ToString());
}
+
if (fieldType == typeof(byte[]))
{
return "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
@@ -163,24 +167,24 @@ public override bool DoesTableExist(IDbCommand dbCmd, string tableName)
var result = dbCmd.GetLongScalar();
return result > 0;
- }
-
- public override bool UseUnicode
- {
- get
- {
- return useUnicode;
- }
- set
- {
- useUnicode = value;
- if (useUnicode && this.DefaultStringLength > 4000)
- {
- this.DefaultStringLength = 4000;
- }
-
- // UpdateStringColumnDefinitions(); is called by changing DefaultStringLength
- }
+ }
+
+ public override bool UseUnicode
+ {
+ get
+ {
+ return useUnicode;
+ }
+ set
+ {
+ useUnicode = value;
+ if (useUnicode && this.DefaultStringLength > 4000)
+ {
+ this.DefaultStringLength = 4000;
+ }
+
+ // UpdateStringColumnDefinitions(); is called by changing DefaultStringLength
+ }
}
}
}
View
1  src/ServiceStack.OrmLite.SqlServerTests/ServiceStack.OrmLite.SqlServerTests.csproj
@@ -73,6 +73,7 @@
<Compile Include="OrmLiteTestBase.cs" />
<Compile Include="SqlServerExpressionVisitorQueryTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TypeWithByteArrayFieldTests.cs" />
<Compile Include="UnicodeTests.cs" />
<Compile Include="UpdateTests.cs" />
<Compile Include="UseCase\SimpleUseCase.cs" />
View
31 src/ServiceStack.OrmLite.SqlServerTests/TypeWithByteArrayFieldTests.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+namespace ServiceStack.OrmLite.SqlServerTests
+{
+ public class TypeWithByteArrayFieldTests : OrmLiteTestBase
+ {
+ [Test]
+ public void CanInsertAndSelectByteArray()
+ {
+ var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
+
+ using (var db = ConnectionString.OpenDbConnection())
+ {
+ db.CreateTable<TypeWithByteArrayField>(true);
+
+ db.Save(orig);
+
+ var target = db.GetById<TypeWithByteArrayField>(orig.Id);
+
+ Assert.AreEqual(orig.Id, target.Id);
+ Assert.AreEqual(orig.Content, target.Content);
+ }
+ }
+ }
+
+ class TypeWithByteArrayField
+ {
+ public int Id { get; set; }
+ public byte[] Content { get; set; }
+ }
+}
View
4 src/ServiceStack.OrmLite/OrmLiteDialectProviderBase.cs
@@ -18,6 +18,7 @@
using ServiceStack.Text;
using System.Diagnostics;
using ServiceStack.Common.Extensions;
+using System.IO;
namespace ServiceStack.OrmLite
{
@@ -257,6 +258,9 @@ public virtual object ConvertDbValue(object value, Type type)
if (value.GetType() == type)
{
+ if (type == typeof(byte[]))
+ return TypeSerializer.DeserializeFromStream<byte[]>(new MemoryStream((byte[])value));
+
return value;
}
View
1  tests/ServiceStack.OrmLite.FirebirdTests/ServiceStack.OrmLite.FirebirdTests.csproj
@@ -66,6 +66,7 @@
<Compile Include="Expressions\StringFunctionTests.cs" />
<Compile Include="Expressions\TestType.cs" />
<Compile Include="Expressions\UnaryExpressionsTest.cs" />
+ <Compile Include="TypeWithByteArrayFieldTests.cs" />
<Compile Include="UseCase\SimpleUseCase.cs" />
<Compile Include="UseCase\CustomerOrdersUseCase.cs" />
<Compile Include="UseCase\SchemaUseCase.cs" />
View
31 tests/ServiceStack.OrmLite.FirebirdTests/TypeWithByteArrayFieldTests.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+namespace ServiceStack.OrmLite.FirebirdTests
+{
+ public class TypeWithByteArrayFieldTests : OrmLiteTestBase
+ {
+ [Test]
+ public void CanInsertAndSelectByteArray()
+ {
+ var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
+
+ using (var db = ConnectionString.OpenDbConnection())
+ {
+ db.CreateTable<TypeWithByteArrayField>(true);
+
+ db.Save(orig);
+
+ var target = db.GetById<TypeWithByteArrayField>(orig.Id);
+
+ Assert.AreEqual(orig.Id, target.Id);
+ Assert.AreEqual(orig.Content, target.Content);
+ }
+ }
+ }
+
+ class TypeWithByteArrayField
+ {
+ public int Id { get; set; }
+ public byte[] Content { get; set; }
+ }
+}
View
483 tests/ServiceStack.OrmLite.Tests/ServiceStack.OrmLite.Tests.csproj
@@ -1,248 +1,249 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{9B64F4A7-C008-46A8-AD6F-99626DCFEFBD}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>ServiceStack.OrmLite.Tests</RootNamespace>
- <AssemblyName>ServiceStack.OrmLite.Tests</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <OldToolsVersion>3.5</OldToolsVersion>
- <UpgradeBackupLocation />
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>x86</PlatformTarget>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>x86</PlatformTarget>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="ServiceStack.Text">
- <HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.ComponentModel.DataAnnotations">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data.Entity" />
- <Reference Include="System.Runtime.Serialization">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Security" />
- <Reference Include="System.Xml.Linq">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data.DataSetExtensions">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- <Reference Include="Mono.Data.Sqlite">
- <HintPath>..\..\lib\tests\Mono.Data.Sqlite.dll</HintPath>
- </Reference>
- <Reference Include="Northwind.Common">
- <HintPath>..\..\lib\tests\Northwind.Common.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework">
- <HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Common">
- <HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Common.Tests">
- <HintPath>..\..\lib\tests\ServiceStack.Common.Tests.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Interfaces">
- <HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ApiExpressionTests.cs" />
- <Compile Include="EnumTests.cs" />
- <Compile Include="ExpressionVisitorTests.cs" />
- <Compile Include="Expression\AdditiveExpressionsTest.cs" />
- <Compile Include="Expression\ConditionalExpressionTest.cs" />
- <Compile Include="Expression\EqualityExpressionsTest.cs" />
- <Compile Include="Expression\ExpressionChainingUseCase.cs" />
- <Compile Include="Expression\ExpressionsTestBase.cs" />
- <Compile Include="Expression\LogicalExpressionsTest.cs" />
- <Compile Include="Expression\MultiplicativeExpressionsTest.cs" />
- <Compile Include="Expression\OrmLiteCountTests.cs" />
- <Compile Include="Expression\PrimaryExpressionsTest.cs" />
- <Compile Include="Expression\RelationalExpressionsTest.cs" />
- <Compile Include="Expression\StringFunctionTests.cs" />
- <Compile Include="Expression\TestType.cs" />
- <Compile Include="Expression\UnaryExpressionsTest.cs" />
- <Compile Include="ForeignKeyAttributeTests.cs" />
- <Compile Include="OrmLiteDropTableTests.cs" />
- <Compile Include="OrmLiteQueryTests.cs" />
- <Compile Include="LocalizationTests.cs" />
- <Compile Include="OrmLiteConnectionFactoryTests.cs" />
- <Compile Include="OrmLiteUtilExtensionsTests.cs" />
- <Compile Include="ShippersExample.cs" />
- <Compile Include="NorthwindPerfTests.cs" />
- <Compile Include="OrmLiteComplexTypesTests.cs" />
- <Compile Include="OrmLiteNorthwindTests.cs" />
- <Compile Include="OrmLiteSaveTests.cs" />
- <Compile Include="Properties\Settings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTimeSharedInput>True</DesignTimeSharedInput>
- <DependentUpon>Settings.settings</DependentUpon>
- </Compile>
- <Compile Include="SqlFormatTests.cs" />
- <Compile Include="OrmLiteTransactionTests.cs" />
- <Compile Include="OrmLiteBasicPersistenceProviderTests.cs" />
- <Compile Include="OrmLiteConnectionTests.cs" />
- <Compile Include="OrmLiteDeleteTests.cs" />
- <Compile Include="OrmLiteUpdateTests.cs" />
- <Compile Include="OrmLiteSelectTests.cs" />
- <Compile Include="OrmLiteCreateTableWithIndexesTests.cs" />
- <Compile Include="OrmLiteCreateTableTests.cs" />
- <Compile Include="OrmLiteInsertTests.cs" />
- <Compile Include="OrmLiteTestBase.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SqlBuilderTests.cs" />
- <Compile Include="SqlServerProviderTests.cs" />
- <Compile Include="UseCase\CustomerOrdersUseCase.cs" />
- <Compile Include="UseCase\SchemaUseCase.cs" />
- <Compile Include="UseCase\ShardingUseCase.cs" />
- <Compile Include="UseCase\SimpleUseCase.cs" />
- <Compile Include="OrmLiteGetScalarTests.cs" />
- <Compile Include="OrmLiteCreateTableWithNamingStrategyTest.cs" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="..\..\lib\sqlite3.dll">
- <Link>sqlite3.dll</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- <Content Include="App_Data\Database1.mdf">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="App_Data\Database1_log.ldf">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- <DependentUpon>Database1.mdf</DependentUpon>
- </Content>
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Sql.Server.Express.10.0">
- <Visible>False</Visible>
- <ProductName>SQL Server 2008 Express</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Sql.Server.Express.9.2">
- <Visible>False</Visible>
- <ProductName>SQL Server 2005 Express Edition SP2 %28x86%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
- <Visible>False</Visible>
- <ProductName>Windows Installer 4.5</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <ItemGroup>
- <None Include="app.config" />
- <None Include="App_Data\sql\instnwnd.Ingres.sql" />
- <None Include="App_Data\sql\instnwnd.MySql.sql" />
- <None Include="App_Data\sql\instnwnd.Oracle.sql" />
- <None Include="App_Data\sql\instnwnd.PostgreSQL.sql" />
- <None Include="App_Data\sql\instnwnd.SQLite.sql" />
- <None Include="App_Data\sql\instnwnd.SqlServer.sql" />
- <None Include="Properties\Settings.settings">
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\src\ServiceStack.OrmLite.Sqlite\ServiceStack.OrmLite.Sqlite.csproj">
- <Project>{CF68A37D-D071-469D-AE04-68594CB95382}</Project>
- <Name>ServiceStack.OrmLite.Sqlite</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\src\ServiceStack.OrmLite.SqlServer\ServiceStack.OrmLite.SqlServer.csproj">
- <Project>{1887DC99-9139-43E3-A7AA-6D74714B3A5D}</Project>
- <Name>ServiceStack.OrmLite.SqlServer</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\src\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
- <Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
- <Name>ServiceStack.OrmLite</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9B64F4A7-C008-46A8-AD6F-99626DCFEFBD}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ServiceStack.OrmLite.Tests</RootNamespace>
+ <AssemblyName>ServiceStack.OrmLite.Tests</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation />
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.Entity" />
+ <Reference Include="System.Runtime.Serialization">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Security" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Mono.Data.Sqlite">
+ <HintPath>..\..\lib\tests\Mono.Data.Sqlite.dll</HintPath>
+ </Reference>
+ <Reference Include="Northwind.Common">
+ <HintPath>..\..\lib\tests\Northwind.Common.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Common">
+ <HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Common.Tests">
+ <HintPath>..\..\lib\tests\ServiceStack.Common.Tests.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Interfaces">
+ <HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ApiExpressionTests.cs" />
+ <Compile Include="EnumTests.cs" />
+ <Compile Include="ExpressionVisitorTests.cs" />
+ <Compile Include="Expression\AdditiveExpressionsTest.cs" />
+ <Compile Include="Expression\ConditionalExpressionTest.cs" />
+ <Compile Include="Expression\EqualityExpressionsTest.cs" />
+ <Compile Include="Expression\ExpressionChainingUseCase.cs" />
+ <Compile Include="Expression\ExpressionsTestBase.cs" />
+ <Compile Include="Expression\LogicalExpressionsTest.cs" />
+ <Compile Include="Expression\MultiplicativeExpressionsTest.cs" />
+ <Compile Include="Expression\OrmLiteCountTests.cs" />
+ <Compile Include="Expression\PrimaryExpressionsTest.cs" />
+ <Compile Include="Expression\RelationalExpressionsTest.cs" />
+ <Compile Include="Expression\StringFunctionTests.cs" />
+ <Compile Include="Expression\TestType.cs" />
+ <Compile Include="Expression\UnaryExpressionsTest.cs" />
+ <Compile Include="ForeignKeyAttributeTests.cs" />
+ <Compile Include="OrmLiteDropTableTests.cs" />
+ <Compile Include="OrmLiteQueryTests.cs" />
+ <Compile Include="LocalizationTests.cs" />
+ <Compile Include="OrmLiteConnectionFactoryTests.cs" />
+ <Compile Include="OrmLiteUtilExtensionsTests.cs" />
+ <Compile Include="ShippersExample.cs" />
+ <Compile Include="NorthwindPerfTests.cs" />
+ <Compile Include="OrmLiteComplexTypesTests.cs" />
+ <Compile Include="OrmLiteNorthwindTests.cs" />
+ <Compile Include="OrmLiteSaveTests.cs" />
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
+ <Compile Include="SqlFormatTests.cs" />
+ <Compile Include="OrmLiteTransactionTests.cs" />
+ <Compile Include="OrmLiteBasicPersistenceProviderTests.cs" />
+ <Compile Include="OrmLiteConnectionTests.cs" />
+ <Compile Include="OrmLiteDeleteTests.cs" />
+ <Compile Include="OrmLiteUpdateTests.cs" />
+ <Compile Include="OrmLiteSelectTests.cs" />
+ <Compile Include="OrmLiteCreateTableWithIndexesTests.cs" />
+ <Compile Include="OrmLiteCreateTableTests.cs" />
+ <Compile Include="OrmLiteInsertTests.cs" />
+ <Compile Include="OrmLiteTestBase.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SqlBuilderTests.cs" />
+ <Compile Include="SqlServerProviderTests.cs" />
+ <Compile Include="TypeWithByteArrayFieldTests.cs" />
+ <Compile Include="UseCase\CustomerOrdersUseCase.cs" />
+ <Compile Include="UseCase\SchemaUseCase.cs" />
+ <Compile Include="UseCase\ShardingUseCase.cs" />
+ <Compile Include="UseCase\SimpleUseCase.cs" />
+ <Compile Include="OrmLiteGetScalarTests.cs" />
+ <Compile Include="OrmLiteCreateTableWithNamingStrategyTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="..\..\lib\sqlite3.dll">
+ <Link>sqlite3.dll</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="App_Data\Database1.mdf">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="App_Data\Database1_log.ldf">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <DependentUpon>Database1.mdf</DependentUpon>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Sql.Server.Express.10.0">
+ <Visible>False</Visible>
+ <ProductName>SQL Server 2008 Express</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Sql.Server.Express.9.2">
+ <Visible>False</Visible>
+ <ProductName>SQL Server 2005 Express Edition SP2 %28x86%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 4.5</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="App_Data\sql\instnwnd.Ingres.sql" />
+ <None Include="App_Data\sql\instnwnd.MySql.sql" />
+ <None Include="App_Data\sql\instnwnd.Oracle.sql" />
+ <None Include="App_Data\sql\instnwnd.PostgreSQL.sql" />
+ <None Include="App_Data\sql\instnwnd.SQLite.sql" />
+ <None Include="App_Data\sql\instnwnd.SqlServer.sql" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\ServiceStack.OrmLite.Sqlite\ServiceStack.OrmLite.Sqlite.csproj">
+ <Project>{CF68A37D-D071-469D-AE04-68594CB95382}</Project>
+ <Name>ServiceStack.OrmLite.Sqlite</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\src\ServiceStack.OrmLite.SqlServer\ServiceStack.OrmLite.SqlServer.csproj">
+ <Project>{1887DC99-9139-43E3-A7AA-6D74714B3A5D}</Project>
+ <Name>ServiceStack.OrmLite.SqlServer</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\src\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
+ <Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
+ <Name>ServiceStack.OrmLite</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
- -->
+ -->
</Project>
View
31 tests/ServiceStack.OrmLite.Tests/TypeWithByteArrayFieldTests.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+namespace ServiceStack.OrmLite.Tests
+{
+ public class TypeWithByteArrayFieldTests : OrmLiteTestBase
+ {
+ [Test]
+ public void CanInsertAndSelectByteArray()
+ {
+ var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
+
+ using (var db = ConnectionString.OpenDbConnection())
+ {
+ db.CreateTable<TypeWithByteArrayField>(true);
+
+ db.Save(orig);
+
+ var target = db.GetById<TypeWithByteArrayField>(orig.Id);
+
+ Assert.AreEqual(orig.Id, target.Id);
+ Assert.AreEqual(orig.Content, target.Content);
+ }
+ }
+ }
+
+ class TypeWithByteArrayField
+ {
+ public int Id { get; set; }
+ public byte[] Content { get; set; }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.