//ProductController.cs
IQueryable<System_ExchangeRateEntity> qRate = _context.System_ExchangeRate.AsQueryable();
var latestCurrency = qRate.ToList()
.Where(r => r.updateDate.CompareTo(fromdate) >= 0 && r.updateDate.CompareTo(todate) < 0)
.GroupBy(r => new { r.fromCurrency, r.toCurrency })
.Select(g => g.OrderByDescending(r => r.rateID).FirstOrDefault());
var unitPrice = from l in latestCurrency
join i in qInvoices on l.toCurrency equals i.Inv_Currency into table2
from i in table2.ToList()
join ii in qInvoicesItem on i.Inv_ID equals ii.Inv_ID into table3
from ii in table3.ToList()
join m in qMember on i.Buyer_ID equals m.Member_ID into table1
from m in table1.ToList()
where i.Inv_Status != "Cancelled"
&& i.Inv_Type == "WS"
&& (i.Order_Date > dateCutoff)
&& (ii.Product_ID == filterProductID)
select new
{
ii.Product_ID,
ii.Order_Qty,
ii.UnitPrice,
l.rate,
m.Member_Country
};
//Program.cs
builder.Services.AddDbContext<ApplicationDBContext>(options =>
{
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
options.LogTo(Console.WriteLine, LogLevel.Information);
});
However, I can just see the SQL for _context.System_ExchangeRate.AsQueryable() but the SQL for unitPrice is missing. I also tried LINQPAD but the change of code is massive. Any idea for outputing the SQL is appreciated.
I am trying to output SQL for the unitPrice. So that I can add index in the database clearly.
New contributor
jp ddlam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.