static void Main(string[] args) { var sqlConnectionSb = new SQLiteConnectionStringBuilder { DataSource = ":memory:" }; using (var sql = new SQLiteBlobDemo(sqlConnectionSb)) { sql.CreateTable(); byte[] test = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; int arrayId = sql.UploadByByteArray(new MemoryStream(test)); int blobId = sql.UploadByBlob(new MemoryStream(test)); byte[] res1 = sql.DownloadByByteArray(arrayId); byte[] res2 = sql.DownloadByByteArray(blobId); byte[] res3 = sql.DownloadByBlob(arrayId); byte[] res4 = sql.DownloadByBlob(blobId); Console.WriteLine("test: " + String.Join(", ", test.Select(bin => bin.ToString("X2")))); Console.WriteLine("res1 is match: " + Enumerable.SequenceEqual(test, res1)); Console.WriteLine("res2 is match: " + Enumerable.SequenceEqual(test, res2)); Console.WriteLine("res3 is match: " + Enumerable.SequenceEqual(test, res3)); Console.WriteLine("res4 is match: " + Enumerable.SequenceEqual(test, res4)); } Console.WriteLine("press any key..."); Console.ReadKey(); }
static void Main(string[] args) { var sqlConnectionSb = new SQLiteConnectionStringBuilder { DataSource = ":memory:" }; using (var sql = new SQLiteBlobDemo(sqlConnectionSb)) { sql.CreateTable(); byte[] test = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; Console.WriteLine("test: " + String.Join(", ", test.Select(bin => bin.ToString("X2")))); long arrayId = sql.InsertDataByteArray(new MemoryStream(test)); long blobId108 = sql.InsertDataBlob108(new MemoryStream(test)); long blobId109 = sql.InsertDataBlob109(new MemoryStream(test)); foreach (var registeredId in new[] { arrayId, blobId108, blobId109 }) { byte[] selectByteArray = sql.GetDataByteArray(registeredId); byte[] selectBlobId108 = sql.GetDataBlob108(registeredId); byte[] selectBlobId109 = sql.GetDataBlob109(registeredId); Console.WriteLine("insert[" + registeredId + "]: " + String.Join(", ", selectByteArray.Select(bin => bin.ToString("X2")))); Console.WriteLine("selectByteArray is match: " + Enumerable.SequenceEqual(test, selectByteArray)); Console.WriteLine("selectBlobId108 is match: " + Enumerable.SequenceEqual(test, selectBlobId108)); Console.WriteLine("selectBlobId109 is match: " + Enumerable.SequenceEqual(test, selectBlobId109)); } } Console.WriteLine("press any key..."); Console.ReadKey(); }