mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Fix entity framework queries to work in netcoreapp3.0
This commit is contained in:
parent
f4977e7f9f
commit
536f98b566
6 changed files with 20 additions and 14 deletions
|
@ -3037,7 +3037,8 @@ noninventoryitem:
|
|||
private static bool IsMapped(Invoice invoice, ApplicationDbContext ctx)
|
||||
{
|
||||
var h = BitcoinAddress.Create(invoice.BitcoinAddress, Network.RegTest).ScriptPubKey.Hash.ToString();
|
||||
return ctx.AddressInvoices.FirstOrDefault(i => i.InvoiceDataId == invoice.Id && i.GetAddress() == h) != null;
|
||||
return (ctx.AddressInvoices.Where(i => i.InvoiceDataId == invoice.Id).ToArrayAsync().GetAwaiter().GetResult())
|
||||
.Where(i => i.GetAddress() == h).Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace BTCPayServer.Controllers
|
||||
{
|
||||
[Filters.BitpayAPIConstraint(false)]
|
||||
public partial class InvoiceController : Controller
|
||||
{
|
||||
InvoiceRepository _InvoiceRepository;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BTCPayServer.HostedServices
|
|||
|
||||
internal override Task[] InitializeTasks()
|
||||
{
|
||||
return new[]
|
||||
return new Task[]
|
||||
{
|
||||
CreateLoopTask(RefreshCoinAverageSupportedExchanges),
|
||||
CreateLoopTask(RefreshCoinAverageSettings),
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace BTCPayServer.Hosting
|
|||
// StyleSrc = "'self' 'unsafe-inline'",
|
||||
// ScriptSrc = "'self' 'unsafe-inline'"
|
||||
//});
|
||||
}).AddControllersAsServices();
|
||||
}).AddNewtonsoftJson().AddControllersAsServices();
|
||||
services.TryAddScoped<ContentSecurityPolicies>();
|
||||
services.Configure<IdentityOptions>(options =>
|
||||
{
|
||||
|
@ -255,10 +255,14 @@ namespace BTCPayServer.Hosting
|
|||
forwardingOptions.ForwardedHeaders = ForwardedHeaders.All;
|
||||
app.UseForwardedHeaders(forwardingOptions);
|
||||
#if !NETCOREAPP21
|
||||
app.UseRouting();
|
||||
app.UsePayServer();
|
||||
app.UseRouting();
|
||||
#endif
|
||||
app.UseCors();
|
||||
#if NETCOREAPP21
|
||||
app.UsePayServer();
|
||||
#endif
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseProviderStorage(options);
|
||||
app.UseAuthentication();
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace BTCPayServer.Security.Bitpay
|
|||
{
|
||||
using (StreamReader reader = new StreamReader(httpContext.Request.Body, Encoding.UTF8, true, 1024, true))
|
||||
{
|
||||
body = reader.ReadToEnd();
|
||||
body = await reader.ReadToEndAsync();
|
||||
}
|
||||
httpContext.Request.Body.Position = 0;
|
||||
}
|
||||
|
|
|
@ -86,12 +86,12 @@ retry:
|
|||
using (var db = _ContextFactory.CreateContext())
|
||||
{
|
||||
return (await db.AddressInvoices
|
||||
.Include(a => a.InvoiceData.Payments)
|
||||
.Include(a => a.InvoiceData.RefundAddresses)
|
||||
#pragma warning disable CS0618
|
||||
.Where(a => addresses.Contains(a.Address))
|
||||
#pragma warning restore CS0618
|
||||
.Select(a => a.InvoiceData)
|
||||
.Include(a => a.Payments)
|
||||
.Include(a => a.RefundAddresses)
|
||||
.ToListAsync()).Select(ToEntity);
|
||||
}
|
||||
}
|
||||
|
@ -491,13 +491,13 @@ retry:
|
|||
|
||||
if (queryObject.InvoiceId != null && queryObject.InvoiceId.Length > 0)
|
||||
{
|
||||
var statusSet = queryObject.InvoiceId.ToHashSet();
|
||||
var statusSet = queryObject.InvoiceId.ToHashSet().ToArray();
|
||||
query = query.Where(i => statusSet.Contains(i.Id));
|
||||
}
|
||||
|
||||
if (queryObject.StoreId != null && queryObject.StoreId.Length > 0)
|
||||
{
|
||||
var stores = queryObject.StoreId.ToHashSet();
|
||||
var stores = queryObject.StoreId.ToHashSet().ToArray();
|
||||
query = query.Where(i => stores.Contains(i.StoreDataId));
|
||||
}
|
||||
|
||||
|
@ -508,8 +508,8 @@ retry:
|
|||
|
||||
if (!string.IsNullOrEmpty(queryObject.TextSearch))
|
||||
{
|
||||
var ids = new HashSet<string>(SearchInvoice(queryObject.TextSearch));
|
||||
if (ids.Count == 0)
|
||||
var ids = new HashSet<string>(SearchInvoice(queryObject.TextSearch)).ToArray();
|
||||
if (ids.Length == 0)
|
||||
{
|
||||
// Hacky way to return an empty query object. The nice way is much too elaborate:
|
||||
// https://stackoverflow.com/questions/33305495/how-to-return-empty-iqueryable-in-an-async-repository-method
|
||||
|
@ -526,18 +526,18 @@ retry:
|
|||
|
||||
if (queryObject.OrderId != null && queryObject.OrderId.Length > 0)
|
||||
{
|
||||
var statusSet = queryObject.OrderId.ToHashSet();
|
||||
var statusSet = queryObject.OrderId.ToHashSet().ToArray();
|
||||
query = query.Where(i => statusSet.Contains(i.OrderId));
|
||||
}
|
||||
if (queryObject.ItemCode != null && queryObject.ItemCode.Length > 0)
|
||||
{
|
||||
var statusSet = queryObject.ItemCode.ToHashSet();
|
||||
var statusSet = queryObject.ItemCode.ToHashSet().ToArray();
|
||||
query = query.Where(i => statusSet.Contains(i.ItemCode));
|
||||
}
|
||||
|
||||
if (queryObject.Status != null && queryObject.Status.Length > 0)
|
||||
{
|
||||
var statusSet = queryObject.Status.ToHashSet();
|
||||
var statusSet = queryObject.Status.ToHashSet().ToArray();
|
||||
query = query.Where(i => statusSet.Contains(i.Status));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue