Kavita/API/Helpers/SQLHelper.cs
Joseph Milazzo 28688ada8e
In-Depth Filtering (#850)
* Laying the foundation for the filter rework

* Filtering by Genre is now possible.

* Cleaned up code and preparing for People filtering

* People filtering is hooked up for the frontend

* Filtering now works. On Deck does not work with filtering currently due to a unique implementation.

* More cleanup

* Implemented the ability to reset the filters

* Added a mobile drawer for filtering

* Added some additional cases for NaturalSortComparer. Filter now uses a drawer on smaller screens.

* Fixed a bug where backup service was not pointing to the correct directory.

* Undid the fix, it's working as expected
2021-12-15 08:23:10 -08:00

32 lines
807 B
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using API.DTOs;
using Microsoft.EntityFrameworkCore;
namespace API.Helpers
{
public static class SqlHelper
{
public static List<T> RawSqlQuery<T>(DbContext context, string query, Func<DbDataReader, T> map)
{
using var command = context.Database.GetDbConnection().CreateCommand();
command.CommandText = query;
command.CommandType = CommandType.Text;
context.Database.OpenConnection();
using var result = command.ExecuteReader();
var entities = new List<T>();
while (result.Read())
{
entities.Add(map(result));
}
return entities;
}
}
}