|
|
|
@ -4,7 +4,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using SQLitePCL.pretty;
|
|
|
|
|
|
|
|
|
@ -66,7 +65,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Guid ReadGuidFromBlob(this IResultSetValue result)
|
|
|
|
|
public static Guid ReadGuidFromBlob(this ResultSetValue result)
|
|
|
|
|
{
|
|
|
|
|
return new Guid(result.ToBlob());
|
|
|
|
|
}
|
|
|
|
@ -87,7 +86,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
private static string GetDateTimeKindFormat(DateTimeKind kind)
|
|
|
|
|
=> (kind == DateTimeKind.Utc) ? DatetimeFormatUtc : DatetimeFormatLocal;
|
|
|
|
|
|
|
|
|
|
public static DateTime ReadDateTime(this IResultSetValue result)
|
|
|
|
|
public static DateTime ReadDateTime(this ResultSetValue result)
|
|
|
|
|
{
|
|
|
|
|
var dateText = result.ToString();
|
|
|
|
|
|
|
|
|
@ -98,7 +97,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
DateTimeStyles.None).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryReadDateTime(this IReadOnlyList<IResultSetValue> reader, int index, out DateTime result)
|
|
|
|
|
public static bool TryReadDateTime(this IReadOnlyList<ResultSetValue> reader, int index, out DateTime result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -119,7 +118,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetGuid(this IReadOnlyList<IResultSetValue> reader, int index, out Guid result)
|
|
|
|
|
public static bool TryGetGuid(this IReadOnlyList<ResultSetValue> reader, int index, out Guid result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -132,17 +131,17 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsDbNull(this IResultSetValue result)
|
|
|
|
|
public static bool IsDbNull(this ResultSetValue result)
|
|
|
|
|
{
|
|
|
|
|
return result.SQLiteType == SQLiteType.Null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetString(this IReadOnlyList<IResultSetValue> result, int index)
|
|
|
|
|
public static string GetString(this IReadOnlyList<ResultSetValue> result, int index)
|
|
|
|
|
{
|
|
|
|
|
return result[index].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetString(this IReadOnlyList<IResultSetValue> reader, int index, out string result)
|
|
|
|
|
public static bool TryGetString(this IReadOnlyList<ResultSetValue> reader, int index, out string result)
|
|
|
|
|
{
|
|
|
|
|
result = null;
|
|
|
|
|
var item = reader[index];
|
|
|
|
@ -155,12 +154,12 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool GetBoolean(this IReadOnlyList<IResultSetValue> result, int index)
|
|
|
|
|
public static bool GetBoolean(this IReadOnlyList<ResultSetValue> result, int index)
|
|
|
|
|
{
|
|
|
|
|
return result[index].ToBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetBoolean(this IReadOnlyList<IResultSetValue> reader, int index, out bool result)
|
|
|
|
|
public static bool TryGetBoolean(this IReadOnlyList<ResultSetValue> reader, int index, out bool result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -173,7 +172,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetInt32(this IReadOnlyList<IResultSetValue> reader, int index, out int result)
|
|
|
|
|
public static bool TryGetInt32(this IReadOnlyList<ResultSetValue> reader, int index, out int result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -186,12 +185,12 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static long GetInt64(this IReadOnlyList<IResultSetValue> result, int index)
|
|
|
|
|
public static long GetInt64(this IReadOnlyList<ResultSetValue> result, int index)
|
|
|
|
|
{
|
|
|
|
|
return result[index].ToInt64();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetInt64(this IReadOnlyList<IResultSetValue> reader, int index, out long result)
|
|
|
|
|
public static bool TryGetInt64(this IReadOnlyList<ResultSetValue> reader, int index, out long result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -204,7 +203,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetSingle(this IReadOnlyList<IResultSetValue> reader, int index, out float result)
|
|
|
|
|
public static bool TryGetSingle(this IReadOnlyList<ResultSetValue> reader, int index, out float result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -217,7 +216,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryGetDouble(this IReadOnlyList<IResultSetValue> reader, int index, out double result)
|
|
|
|
|
public static bool TryGetDouble(this IReadOnlyList<ResultSetValue> reader, int index, out double result)
|
|
|
|
|
{
|
|
|
|
|
var item = reader[index];
|
|
|
|
|
if (item.IsDbNull())
|
|
|
|
@ -230,7 +229,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Guid GetGuid(this IReadOnlyList<IResultSetValue> result, int index)
|
|
|
|
|
public static Guid GetGuid(this IReadOnlyList<ResultSetValue> result, int index)
|
|
|
|
|
{
|
|
|
|
|
return result[index].ReadGuidFromBlob();
|
|
|
|
|
}
|
|
|
|
@ -442,7 +441,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<IReadOnlyList<IResultSetValue>> ExecuteQuery(this IStatement statement)
|
|
|
|
|
public static IEnumerable<IReadOnlyList<ResultSetValue>> ExecuteQuery(this IStatement statement)
|
|
|
|
|
{
|
|
|
|
|
while (statement.MoveNext())
|
|
|
|
|
{
|
|
|
|
|