如何使用MongoDB和.NET的C#驅動程序執行以下操作。MongoDB C# - 如何執行以下操作
說我有以下的集合(忽略是否有語法錯誤):
{_id: "2312321321sdd", "Ticker": "AAPL", "CompanyName" : "APPLE", "Viewed": "2013-05-13"}
{_id: "2312321321sde", "Ticker": "AAPL", "CompanyName" : "APPLE", "Viewed": "2013-05-12"}
{_id: "2312321321sdf", "Ticker": "GOOG", "CompanyName" : "GOOGLE", "Viewed": "2013-05-12"}
{_id: "2312321321sdg", "Ticker": "MSFT", "CompanyName" : "MICROSOFT", "Viewed": "2013-05-12"}
{_id: "2312321321sdh", "Ticker": "MSFT", "CompanyName" : "MICROSOFT", "Viewed": "2013-05-11"}
使用C#和/或LINQ與MongoDB的驅動程序,我該如何獲得最新的3瀏覽過的商品,但也DISTINCT作爲好吧,所以同一個TICKER沒有雙重的起伏。因此,最好在下面將得到恢復:提前
{_id: "2312321321sdd", "Ticker": "AAPL", "CompanyName" : "APPLE", "Viewed": "2013-05-13"}
{_id: "2312321321sdf", "Ticker": "GOOG", "CompanyName" : "GOOGLE", "Viewed": "2013-05-12"}
{_id: "2312321321sdg", "Ticker": "MSFT", "CompanyName" : "MICROSOFT", "Viewed": "2013-05-12"}
感謝....
也許地圖減少查詢您在地圖上的地圖,你的減少步驟是返回實體與最新的觀看。 – 2013-05-13 02:42:23
也許是這樣的http://stackoverflow.com/questions/12785550/mongo-mapreduce-select-latest-date – 2013-05-13 02:43:55