-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I added a DB fucntion:
modelBuilder.HasDbFunction(
typeof(DateTimeExtensions).GetMethod(nameof(DateTimeExtensions.MonthsDeltaFractionalDb),
new[] { typeof(DateTimeOffset), typeof(DateTimeOffset) })!)
.HasName("months_delta_fractional");And am using it in a query:
BudgetDetailsResponse? budget = await _dbContext.Companies
.Include(x => x.Orders)
.Include(x => x.Campaigns)
.Where(x => x.Id == companyId)
.Select(x => new BudgetDetailsResponse
{
UsedBudget = x.Orders!
.ExcludeOptionalOrder(excludeOrderId)
.Where(order => Order.UsedBudgetStatuses.Contains(order.Status))
.Sum(order => order.TotalPrice / order.FlightTimeMonths),
}).FirstOrDefaultAsync();With an entity configured as so:
public double FlightTimeMonths => DateTimeExtensions.MonthsDeltaFractionalDb(StartDate, EndDate);
[Projectable]
public int FlightTimeDays => (EndDate - StartDate).Days;
[Projectable]
public double AvgPlaysPerDay => FlightTimeMonths * PlaysPerMonth / FlightTimeDays;
[Projectable]
public double TotalPlays => AvgPlaysPerDay * FlightTimeDays;
[Projectable]
public double TotalPrice => Pricing.GetTotalPrice((int)Math.Round(TotalPlays));It seems that the use of a DBFunction and a projectable together creates a problem?
Metadata
Metadata
Assignees
Labels
No labels