Hi, I’m trying to execute this query
return await ctx.SelectAsync<SchedulerOrderBaseInfo>(ctx
.From<Order_ST>()
.Join<Order_ST, ScheduledOrder>((o1, so1) => o1.Code == so1.OrderCode)
.Join<ScheduledOrder, ScheduledOrderMachine>((so2, som2) => so2.Id == som2.IdOrder)
.Join<ScheduledOrderMachine, ScheduledOrderMachineProcess>((som3, somp3) => som3.Id == somp3.IdOrderMachine)
.Join<ScheduledOrderMachineProcess, ScheduledOrderMachineProcessRepetition>((somp4, sompr4) => somp4.Id == sompr4.IdScheduledOrderMachineProcess)
.Where<Order_ST, ScheduledOrderMachineProcessRepetition>((o5, sompr5) =>
o5.Status != OrderStatusArchived &&
o5.Status != OrderStatusCancelled &&
o5.IsLastRevision &&
sompr5.StartDate <= intervalFinishDate &&
sompr5.FinishDate >= intervalBeginDate)
.GroupBy<ScheduledOrder, ScheduledOrderMachine>((so6, som6) => new { so6.OrderCode, som6.MachineCode })
.Select<ScheduledOrder, ScheduledOrderMachine, ScheduledOrderMachineProcessRepetition>((so7, som7, sompr7) => new SchedulerOrderBaseInfo()
{
OrderCode = so7.OrderCode,
MachineCode = som7.MachineCode,
DoStart = Sql.Min(sompr7.StartDate),
DoEnd = Sql.Max(sompr7.FinishDate)
}));
but I receive this error
InvalidOperationException: variable ‘so7’ of type ‘Mares.Data.Entities.ScheduledOrder’ referenced from scope ‘’, but it is not defined
what I’m doing wrong? I’m sure I’m doing something wrong, but I cannot find where…
Thanks
Enrico