我正在寻找MongoDB
中与Entity Framework
已知的此方法的等效内容:
public List<SomeDto> GetAll()
{
return _context
.Database
.SqlQuery<SomeDto>(@"SELECT id, name FROM Users")
.ToList();
}
我已经有一个mongo脚本,它在某种程度上很复杂:
db.getCollection('Some').aggregate(
[
{
$unwind: '$SocialData'
},
{
$match : {
"ServiceType" : 9
}
},
{
$project : {
mscore: { "$cond": [{ $eq: ["$SocialData.k", "mscore"]}, "$SocialData.v", null]},
uscore: { "$cond": [{ $eq: ["$SocialData.k", "uscore"]}, "$SocialData.v", null]},
scrappedDate : "$ScrappedDate",
url: "$Url"
}
},
{
$group : {
_id : {
url : "$url"
},
mscore: { "$max": "$mscore"},
uscore: { "$max": "$uscore"},
url: { "$first": "$url"},
scrappedDate: { "$last": "$scrappedDate"},
}
},
{
$project : {
id : "$_id.itemId",
lastScrappedDate : "$scrappedDate",
url : "$url",
mscore: "$mscore",
uscore: "$uscore",
}
},
{
$sort : {
mscore: -1,
uscore: -1,
}
}
]
)
我想,如果这是可能的,如果是,如何实现它或什么是解决此任务的最佳方法?