static void MultiThreading()
        {
            using (SqlDatabaseConnection cnn = new SqlDatabaseConnection("schemaname=db;uri=file://@memory;")) // In Memory database.
            {
                try
                {
                    cnn.Open();
                    if (cnn.State != ConnectionState.Open)
                    {
                        Console.WriteLine("Unable to open connection.");
                        return;
                    }
                }
                catch (SqlDatabaseException e)
                {
                    Console.WriteLine("Error: {0}", e.Message);
                    return;
                }

                using (SqlDatabaseCommand cmd = new SqlDatabaseCommand())
                {
                    cmd.Connection  = cnn;
                    cmd.CommandText = "CREATE TABLE IF NOT EXISTS TestTable (ThreadId Integer, Id Integer, RandomText Text, ByteArray Blob);";
                    cmd.ExecuteNonQuery();
                }

                Random rnd = new Random();
                Parallel.For(0, Environment.ProcessorCount,
                             new ParallelOptions
                {
                    MaxDegreeOfParallelism = Environment.ProcessorCount
                },
                             i => {
                    using (SqlDatabaseCommand cmd = new SqlDatabaseCommand())
                    {
                        cmd.Connection = cnn;

                        string RandomPathForText = System.IO.Path.GetRandomFileName();

                        cmd.CommandText = "INSERT INTO TestTable VALUES (@ThreadId, @Id, @RandomText, @ByteArray);";
                        if (!cmd.Parameters.Contains("@ThreadId"))
                        {
                            cmd.Parameters.AddWithValue("@ThreadId", System.Threading.Thread.CurrentThread.ManagedThreadId);
                        }
                        else
                        {
                            cmd.Parameters["@ThreadId"].Value = System.Threading.Thread.CurrentThread.ManagedThreadId;
                        }

                        if (!cmd.Parameters.Contains("@Id"))
                        {
                            cmd.Parameters.AddWithValue("@Id", rnd.Next(1, 100));
                        }
                        else
                        {
                            cmd.Parameters["@Id"].Value = rnd.Next(1, 100);
                        }

                        if (!cmd.Parameters.Contains("@RandomText"))
                        {
                            cmd.Parameters.AddWithValue("@RandomText", RandomPathForText);
                        }
                        else
                        {
                            cmd.Parameters["@RandomText"].Value = RandomPathForText;
                        }

                        if (!cmd.Parameters.Contains("@ByteArray"))
                        {
                            cmd.Parameters.AddWithValue("@ByteArray", Encoding.UTF8.GetBytes(RandomPathForText));
                        }
                        else
                        {
                            cmd.Parameters["@ByteArray"].Value = Encoding.UTF8.GetBytes(RandomPathForText);
                        }

                        cmd.ExecuteNonQuery();
                    }
                });


                using (SqlDatabaseCommand cmd = new SqlDatabaseCommand(cnn))
                {
                    cmd.CommandText = "SELECT * FROM TestTable; ";
                    cmd.ExecuteNonQuery();
                    SqlDatabaseDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        for (int c = 0; c < dr.VisibleFieldCount; c++)
                        {
                            //Console.Write(Encoding.UTF8.GetString(dr.GetFieldValue<byte[]>(c)) + "\t");
                            //byte[] byteArray = (byte[])dr.GetValue(c);
                            if (dr.GetName(c).Equals("ByteArray"))
                            {
                                Console.Write(Encoding.UTF8.GetString(dr.GetFieldValue <byte[]>(c)) + "\t");
                            }
                            else
                            {
                                Console.Write(dr.GetValue(c) + "\t");
                            }
                        }
                        Console.WriteLine("");
                    }
                }
            }
        }