我正在为复杂的 EF 查询而苦苦挣扎
查询传递了一个整数,它定义了回顾股票收盘价的天数,以确定最近的每一天是否低于前一天(即查看回顾期间的每一天价格是否较低) I我正在为如何结合价格测试而苦苦挣扎。我可以检索必要的天数,但不确定我是否可以在一个查询中完成整个过程,或者是否应该将其分解为另一个查询以获得结果。任何帮助表示赞赏。(AddBusinessDays 是我自己的函数,只使用工作日)
Public Shared Function GetDailyEquityDownMoves(ByVal numdaysback As Int32) As List(Of String)
Dim qualifiedDownStocks As New List(Of String)
Using ctx As New QE2DatabaseEntities()
Dim symblist As List(Of Int64) = (From sym In ctx.symbols Select sym.idsymbols).ToList()
For Each symId As Int64 In symblist
Dim query = (From q In ctx.pricedatas
Where q.symid = symId
Join d In ctx.symbols On d.idsymbols Equals symId
Where q.pricedate < DateTime.Now AndAlso q.pricedate > AddBusinessDays(DateTime.Now.AddDays(numdaysback * -1))
Order By q.pricedate Ascending
Select q.closeprice).ToList()
'Now test to see if each closeprice is less than the prior starting with most recent date
'if it qualifies add it to the list
'qualifiedDownStocks.Add(result)
Next
End Using
End Function