diff --git a/nuget/SQLite-net-base/SQLite-net-base.csproj b/nuget/SQLite-net-base/SQLite-net-base.csproj index bf4403f9..8215d3e0 100644 --- a/nuget/SQLite-net-base/SQLite-net-base.csproj +++ b/nuget/SQLite-net-base/SQLite-net-base.csproj @@ -1,7 +1,7 @@ - netstandard1.1 + netstandard2.0 SQLite-net 1.0.0 SQLite-net Official .NET Standard Base Library @@ -31,5 +31,6 @@ + diff --git a/nuget/SQLite-net-sqlcipher/SQLite-net-sqlcipher.csproj b/nuget/SQLite-net-sqlcipher/SQLite-net-sqlcipher.csproj index 86347b67..24ee70da 100644 --- a/nuget/SQLite-net-sqlcipher/SQLite-net-sqlcipher.csproj +++ b/nuget/SQLite-net-sqlcipher/SQLite-net-sqlcipher.csproj @@ -1,7 +1,7 @@ - netstandard1.1 + netstandard2.0 SQLite-net 1.0.0 SQLite-net Official SQLCipher .NET Standard Library @@ -23,6 +23,7 @@ + diff --git a/nuget/SQLite-net-std/SQLite-net-std.csproj b/nuget/SQLite-net-std/SQLite-net-std.csproj index 6b68fdfb..13449ede 100644 --- a/nuget/SQLite-net-std/SQLite-net-std.csproj +++ b/nuget/SQLite-net-std/SQLite-net-std.csproj @@ -1,7 +1,7 @@ - netstandard1.1 + netstandard2.0 SQLite-net 1.0.0 SQLite-net Official .NET Standard Library @@ -23,6 +23,7 @@ + diff --git a/nuget/SQLite-net/SQLite-net.csproj b/nuget/SQLite-net/SQLite-net.csproj index d6ffdb6a..9ed7ac06 100644 --- a/nuget/SQLite-net/SQLite-net.csproj +++ b/nuget/SQLite-net/SQLite-net.csproj @@ -1,5 +1,6 @@  + 10.0 @@ -76,4 +77,5 @@ --> + diff --git a/nuget/SQLite-net/packages.config b/nuget/SQLite-net/packages.config index a948fa85..63eb0e84 100644 --- a/nuget/SQLite-net/packages.config +++ b/nuget/SQLite-net/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file diff --git a/src/SQLite.cs b/src/SQLite.cs index cc6689e9..1e7f7dce 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -35,6 +35,9 @@ using System.Linq.Expressions; using System.Text; using System.Threading; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Json; +using System.IO; #if USE_CSHARP_SQLITE using Sqlite3 = Community.CsharpSqlite.Sqlite3; @@ -2508,6 +2511,9 @@ public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks) else if (clrType == typeof (Guid)) { return "varchar(36)"; } + else if (clrType.GetTypeInfo ().IsDefined (typeof (DataContractAttribute))) { + return SQLite3.LibVersionNumber() >= 3009000 ? "json" : "text"; + } else { throw new NotSupportedException ("Don't know about " + clrType); } @@ -2834,6 +2840,15 @@ internal static void BindParameter (Sqlite3Statement stmt, int index, object val } else if (value is UriBuilder) { SQLite3.BindText (stmt, index, ((UriBuilder)value).ToString (), -1, NegativePointer); + } + else if (value.GetType ().GetTypeInfo ().IsDefined (typeof (DataContractAttribute))) { + using (var stream = new MemoryStream ()) + { + new DataContractJsonSerializer (value.GetType()).WriteObject(stream, value); + var bytes = stream.ToArray (); + var json = Encoding.UTF8.GetString (bytes, 0, bytes.Length); + SQLite3.BindText (stmt, index, json, -1, NegativePointer); + } } else { // Now we could possibly get an enum, retrieve cached info @@ -2950,7 +2965,14 @@ object ReadCol (Sqlite3Statement stmt, int index, SQLite3.ColType type, Type clr else if (clrType == typeof(UriBuilder)) { var text = SQLite3.ColumnString(stmt, index); return new UriBuilder(text); - } + } + else if (clrType.GetTypeInfo ().IsDefined (typeof (DataContractAttribute))) { + var json = SQLite3.ColumnString (stmt, index); + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes (json))) + { + return new DataContractJsonSerializer (clrType).ReadObject (stream); + } + } else { throw new NotSupportedException ("Don't know how to read " + clrType); } diff --git a/tests/ApiDiff/ApiDiff.csproj b/tests/ApiDiff/ApiDiff.csproj index 577d5393..def94bf1 100644 --- a/tests/ApiDiff/ApiDiff.csproj +++ b/tests/ApiDiff/ApiDiff.csproj @@ -33,6 +33,8 @@ ..\..\packages\ListDiff.1.0.7\lib\netstandard1.0\ListDiff.dll + + diff --git a/tests/SQLite.Tests.csproj b/tests/SQLite.Tests.csproj index 674f1cbe..73571998 100644 --- a/tests/SQLite.Tests.csproj +++ b/tests/SQLite.Tests.csproj @@ -37,6 +37,8 @@ + + diff --git a/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj b/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj index 4acd4ebd..18e112f3 100644 --- a/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj +++ b/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj @@ -90,6 +90,7 @@ +