public T SelectBy <T>(string query) where T : new()
        {
            var command = CreateCommand();

            command.CommandText = query;

            using (SQLiteConnection connection = CreateConnection())
            {
                command.Connection = connection;

                using (SQLiteDataReader reader = (SQLiteDataReader)command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T instance = new T();

                        using (new JoeCulture())
                            ObjectExtensions.CreateFrom(instance, reader);

                        return(instance);
                    }
                }
            }

            return(default(T));
        }
        public T SelectBy <T>(object queryObject) where T : new()
        {
            QueryGenerator <T> generator = new QueryGenerator <T>();

            using (SQLiteConnection connection = CreateConnection())
            {
                var properties = queryObject.GetProperties().ToList();

                SQLiteCommand command = generator.GetSelectCommand(properties);

                command.Connection = connection;

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T instance = new T();

                        using (new JoeCulture())
                            ObjectExtensions.CreateFrom(instance, reader);

                        return(instance);
                    }
                }
            }

            return(default(T));
        }
        public T SelectByKey <T>(long key) where T : new()
        {
            QueryGenerator <T> generator = new QueryGenerator <T>();

            using (SQLiteConnection connection = CreateConnection())
            {
                SQLiteCommand command = generator.GetSelectCommand(key.ToString());

                command.Parameters.AddWithValue("@" + generator.Map.PrimaryKey.ColumName, key);
                command.Connection = connection;

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T instance = new T();

                        using (new JoeCulture())
                            ObjectExtensions.CreateFrom(instance, reader);

                        return(instance);
                    }
                }
            }

            return(default(T));
        }
        public IEnumerable <T> SelectAll <T>(IDbCommand command) where T : new()
        {
            using (SQLiteConnection connection = CreateConnection())
            {
                command.Connection = connection;

                using (SQLiteDataReader reader = ((SQLiteCommand)command).ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T instance = new T();

                        using (new JoeCulture())
                            ObjectExtensions.CreateFrom(instance, reader);

                        yield return(instance);
                    }
                }
            }
        }
        /// <summary>
        /// Selects all items from the table associated with T.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IEnumerable <T> SelectAll <T>() where T : new()
        {
            QueryGenerator <T> generator = new QueryGenerator <T>();

            using (SQLiteConnection connection = CreateConnection())
            {
                SQLiteCommand command = generator.GetSelectCommand();

                command.Connection = connection;

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T instance = new T();

                        using (new JoeCulture())
                            ObjectExtensions.CreateFrom(instance, reader);

                        yield return(instance);
                    }
                }
            }
        }