如何使用 MongoDB 和适用于 .NET 的 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"}
提前致谢....