pszczyg

Untitled

Apr 1st, 2017
296
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  var connectionString = RegistryReader.GetFixedConnectionStringFromRegistry();
  2.            using (var connection = new OracleConnection(connectionString))
  3.            {
  4.                //Dla uproszczenia, usuwam poprzednie przyklady z tabeli
  5.                connection.Execute("DELETE FROM GUID_TEST_TABLE");
  6.                //Najbardziej przystepny, niezyciowy GUID
  7.                var testGuid = Guid.Parse("00112233-4455-6677-8899-AABBCCDDEEFF");
  8.                Console.WriteLine($"GUID testowy: {testGuid}");
  9.  
  10.                //Wprowadzam GUID do tabeli
  11.                connection.Execute($"INSERT INTO GUID_TEST_TABLE (ID) VALUES ('{testGuid.ToString("N")}')");
  12.  
  13.                //Odpytuje baze danych
  14.                var rawBytesFromOracle = connection.Query<byte[]>("SELECT * FROM GUID_TEST_TABLE").Single();
  15.                var guidBuiltFromOracleBytes = new Guid(rawBytesFromOracle);
  16.                Console.WriteLine($"Ten sam GUID po wyjeciu z Oracle: {guidBuiltFromOracleBytes}");
  17.            }
RAW Paste Data