0
我有一個複雜的EF查詢掙扎複雜的實體框架查詢
查詢傳遞一個整數,它定義的天數回頭看A股股票收盤價以確定是否從最近每天較低那麼先前的(即看看回顧期間的價格是否較低)我正在努力如何納入價格測試。我可以檢索所需的天數,但不確定是否可以在一個查詢中完成整個過程,或者是否應該將其分解爲另一個查詢以獲得結果。任何幫助讚賞。 (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
感謝您的回覆,enroute首頁,將在那裏測試 – dinotom