forked from ServiceStack/ServiceStack.OrmLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old Expression/Reflection dependency injection cruft and just …
…use conditional compilation. Update with the latest libs.
- Loading branch information
Showing
33 changed files
with
433 additions
and
596 deletions.
There are no files selected for viewing
Binary file modified
BIN
+512 Bytes
(100%)
NuGet/ServiceStack.OrmLite.SqlServer/lib/ServiceStack.Common.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.SqlServer/lib/ServiceStack.Interfaces.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.SqlServer/lib/ServiceStack.OrmLite.SqlServer.dll
Binary file not shown.
Binary file modified
BIN
+4.5 KB
(110%)
NuGet/ServiceStack.OrmLite.SqlServer/lib/ServiceStack.OrmLite.dll
Binary file not shown.
Binary file modified
BIN
+512 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite32/lib/ServiceStack.Common.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite32/lib/ServiceStack.Interfaces.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite32/lib/ServiceStack.OrmLite.SqliteNET.dll
Binary file not shown.
Binary file modified
BIN
+4.5 KB
(110%)
NuGet/ServiceStack.OrmLite.Sqlite32/lib/ServiceStack.OrmLite.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+512 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite64/lib/ServiceStack.Common.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite64/lib/ServiceStack.Interfaces.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NuGet/ServiceStack.OrmLite.Sqlite64/lib/ServiceStack.OrmLite.SqliteNET.dll
Binary file not shown.
Binary file modified
BIN
+4.5 KB
(110%)
NuGet/ServiceStack.OrmLite.Sqlite64/lib/ServiceStack.OrmLite.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
252 changes: 126 additions & 126 deletions
252
src/ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,128 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.SqlClient; | ||
using System.IO; | ||
|
||
namespace ServiceStack.OrmLite.SqlServer | ||
{ | ||
public class SqlServerOrmLiteDialectProvider | ||
: OrmLiteDialectProviderBase | ||
{ | ||
public static SqlServerOrmLiteDialectProvider Instance = new SqlServerOrmLiteDialectProvider(); | ||
|
||
private static DateTime timeSpanOffset = new DateTime(1900,01,01); | ||
|
||
public SqlServerOrmLiteDialectProvider() | ||
{ | ||
base.AutoIncrementDefinition = "IDENTITY(1,1)"; | ||
base.StringColumnDefinition = "VARCHAR(8000)"; | ||
//base.DateTimeColumnDefinition = base.StringColumnDefinition; | ||
base.BoolColumnDefinition = base.IntColumnDefinition; | ||
base.GuidColumnDefinition = "UniqueIdentifier"; | ||
base.RealColumnDefinition = "FLOAT"; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.SqlClient; | ||
using System.IO; | ||
|
||
namespace ServiceStack.OrmLite.SqlServer | ||
{ | ||
public class SqlServerOrmLiteDialectProvider | ||
: OrmLiteDialectProviderBase | ||
{ | ||
public static SqlServerOrmLiteDialectProvider Instance = new SqlServerOrmLiteDialectProvider(); | ||
|
||
private static DateTime timeSpanOffset = new DateTime(1900,01,01); | ||
|
||
public SqlServerOrmLiteDialectProvider() | ||
{ | ||
base.AutoIncrementDefinition = "IDENTITY(1,1)"; | ||
base.StringColumnDefinition = "VARCHAR(8000)"; | ||
//base.DateTimeColumnDefinition = base.StringColumnDefinition; | ||
base.BoolColumnDefinition = base.IntColumnDefinition; | ||
base.GuidColumnDefinition = "UniqueIdentifier"; | ||
base.RealColumnDefinition = "FLOAT"; | ||
base.DecimalColumnDefinition = "DECIMAL(38,6)"; | ||
base.TimeColumnDefinition = "TIME"; //SQLSERVER 2008+ | ||
|
||
base.InitColumnTypeMap(); | ||
} | ||
|
||
public override IDbConnection CreateConnection(string connectionString, Dictionary<string, string> options) | ||
{ | ||
var isFullConnectionString = connectionString.Contains(";"); | ||
|
||
if (!isFullConnectionString) | ||
{ | ||
var filePath = connectionString; | ||
|
||
var filePathWithExt = filePath.ToLower().EndsWith(".mdf") | ||
? filePath | ||
: filePath + ".mdf"; | ||
|
||
var fileName = Path.GetFileName(filePathWithExt); | ||
var dbName = fileName.Substring(0, fileName.Length - ".mdf".Length); | ||
|
||
connectionString = string.Format( | ||
@"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Initial Catalog={1};Integrated Security=True;User Instance=True;", | ||
filePathWithExt, dbName); | ||
} | ||
|
||
if (options != null) | ||
{ | ||
foreach (var option in options) | ||
{ | ||
if (option.Key.ToLower() == "read only") | ||
{ | ||
if (option.Value.ToLower() == "true") | ||
{ | ||
connectionString += "Mode = Read Only;"; | ||
} | ||
continue; | ||
} | ||
connectionString += option.Key + "=" + option.Value + ";"; | ||
} | ||
} | ||
|
||
return new SqlConnection(connectionString); | ||
} | ||
|
||
public override object ConvertDbValue(object value, Type type) | ||
{ | ||
try | ||
{ | ||
if (value == null || value is DBNull) return null; | ||
|
||
if (type == typeof(bool) && !(value is bool)) | ||
{ | ||
var intVal = Convert.ToInt32(value.ToString()); | ||
return intVal != 0; | ||
} | ||
|
||
if (type == typeof(TimeSpan) && value is DateTime) | ||
{ | ||
var dateTimeValue = (DateTime)value; | ||
return dateTimeValue - timeSpanOffset; | ||
} | ||
|
||
return base.ConvertDbValue(value, type); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
public override string GetQuotedValue(object value, Type fieldType) | ||
{ | ||
if (value == null) return "NULL"; | ||
|
||
if (fieldType == typeof(Guid)) | ||
{ | ||
var guidValue = (Guid)value; | ||
return string.Format("CAST('{0}' AS UNIQUEIDENTIFIER)", guidValue); | ||
} | ||
if (fieldType == typeof(DateTime)) | ||
{ | ||
var dateValue = (DateTime)value; | ||
const string iso8601Format = "yyyy-MM-dd HH:mm:ss.fff"; | ||
return base.GetQuotedValue(dateValue.ToString(iso8601Format), typeof(string)); | ||
} | ||
if (fieldType == typeof(bool)) | ||
{ | ||
var boolValue = (bool)value; | ||
return base.GetQuotedValue(boolValue ? 1 : 0, typeof(int)); | ||
} | ||
|
||
return base.GetQuotedValue(value, fieldType); | ||
} | ||
|
||
public override long GetLastInsertId(IDbCommand dbCmd) | ||
{ | ||
dbCmd.CommandText = "SELECT SCOPE_IDENTITY()"; | ||
var result = dbCmd.ExecuteScalar(); | ||
if (result is DBNull) return default(long); | ||
if (result is decimal) return Convert.ToInt64((decimal)result); | ||
return (long)result; | ||
} | ||
} | ||
base.TimeColumnDefinition = "TIME"; //SQLSERVER 2008+ | ||
|
||
base.InitColumnTypeMap(); | ||
} | ||
|
||
public override IDbConnection CreateConnection(string connectionString, Dictionary<string, string> options) | ||
{ | ||
var isFullConnectionString = connectionString.Contains(";"); | ||
|
||
if (!isFullConnectionString) | ||
{ | ||
var filePath = connectionString; | ||
|
||
var filePathWithExt = filePath.ToLower().EndsWith(".mdf") | ||
? filePath | ||
: filePath + ".mdf"; | ||
|
||
var fileName = Path.GetFileName(filePathWithExt); | ||
var dbName = fileName.Substring(0, fileName.Length - ".mdf".Length); | ||
|
||
connectionString = string.Format( | ||
@"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Initial Catalog={1};Integrated Security=True;User Instance=True;", | ||
filePathWithExt, dbName); | ||
} | ||
|
||
if (options != null) | ||
{ | ||
foreach (var option in options) | ||
{ | ||
if (option.Key.ToLower() == "read only") | ||
{ | ||
if (option.Value.ToLower() == "true") | ||
{ | ||
connectionString += "Mode = Read Only;"; | ||
} | ||
continue; | ||
} | ||
connectionString += option.Key + "=" + option.Value + ";"; | ||
} | ||
} | ||
|
||
return new SqlConnection(connectionString); | ||
} | ||
|
||
public override object ConvertDbValue(object value, Type type) | ||
{ | ||
try | ||
{ | ||
if (value == null || value is DBNull) return null; | ||
|
||
if (type == typeof(bool) && !(value is bool)) | ||
{ | ||
var intVal = Convert.ToInt32(value.ToString()); | ||
return intVal != 0; | ||
} | ||
|
||
if (type == typeof(TimeSpan) && value is DateTime) | ||
{ | ||
var dateTimeValue = (DateTime)value; | ||
return dateTimeValue - timeSpanOffset; | ||
} | ||
|
||
return base.ConvertDbValue(value, type); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
public override string GetQuotedValue(object value, Type fieldType) | ||
{ | ||
if (value == null) return "NULL"; | ||
|
||
if (fieldType == typeof(Guid)) | ||
{ | ||
var guidValue = (Guid)value; | ||
return string.Format("CAST('{0}' AS UNIQUEIDENTIFIER)", guidValue); | ||
} | ||
if (fieldType == typeof(DateTime)) | ||
{ | ||
var dateValue = (DateTime)value; | ||
const string iso8601Format = "yyyy-MM-dd HH:mm:ss.fff"; | ||
return base.GetQuotedValue(dateValue.ToString(iso8601Format), typeof(string)); | ||
} | ||
if (fieldType == typeof(bool)) | ||
{ | ||
var boolValue = (bool)value; | ||
return base.GetQuotedValue(boolValue ? 1 : 0, typeof(int)); | ||
} | ||
|
||
return base.GetQuotedValue(value, fieldType); | ||
} | ||
|
||
public override long GetLastInsertId(IDbCommand dbCmd) | ||
{ | ||
dbCmd.CommandText = "SELECT SCOPE_IDENTITY()"; | ||
var result = dbCmd.ExecuteScalar(); | ||
if (result is DBNull) return default(long); | ||
if (result is decimal) return Convert.ToInt64((decimal)result); | ||
return (long)result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.