CommentCollection
{
"_id":"5b63f0f23846b70011330889",
"CommentType":"task",
"EntityReferenceId":"6082ef25-6f9a-4874-a832-f72e0f693409",
"CommentLink":null,
"EntityName":"task2",
"participants":[
ObjectId("52ffc4a5d85242602e000000"),
ObjectId("52ffc4a5d85242602e000001")
],
"Threads":[
{
"_id":"69bcef71-3695-4340-bdec-4a6e4c58c490",
"CommentType":"task",
"UserId":ObjectId("52ffc4a5d85242602e000000"),
"CommentByUserType":"Admin",
"EntityReferenceId":"6082ef25-6f9a-4874-a832-f72e0f693409",
"Content":"fdffd",
"ProjectName":null,
"PostedDate":"2018-08-03T13:03:05.939Z",
"Active":true,
"Attachment":[
]
}
Run Code Online (Sandbox Code Playgroud)
另一个集合是
userCollection
{
"Id":ObjectId("52ffc4a5d85242602e000000"),
"Name":"Pms Admin",
"Email":"pms@xtrastaff.com",
"Type":"Admin",
"UserId":"6082ef25-6f9a-4874-a832-f72e0f693409",
"UserImage":"6082ef25-6f9a-4874-a832-f72e0f693409"
}
Run Code Online (Sandbox Code Playgroud)
在CommentCollection中有一个“参与者”数组,它存储用户的 id(来自用户集合)。
我的要求是加入这两个集合以获取我的 asp.net core 项目(Linq)中的用户详细信息。参与者包含 id 列表
linq asp.net-mvc mongodb asp.net-core-mvc mongodb-csharp-2.0
最近我开始使用 MongoDB。我必须使用 mongodb C# 驱动程序从 mongodb 读取特定字段(列)。这意味着无论值如何,我都必须读取特定字段。我只需要指定字段。我的数据中有非结构化数据db.so 我的项目中没有模型类。
我使用 Getcollection<> 从 C# 库中读取 Collection。然后在我坚持完成这项任务之后。
我怎样才能实现?
mongodb mongodb-query mongodb-csharp-2.0 mongodb-.net-driver
我的数据库表中有 HH.mm 格式的“TimeClocked”,我想使用 LINQ 对所有“TimeClocked”求和。
我试过这个聚合函数。
var data = _projectDbContext
.Tasks
.Where(x => x.Project.CompanyId == companyId && x.Status == true)
.Select(e => TimeSpan.Parse(e.TimeClocked))
.Aggregate(TimeSpan.FromMinutes(0), (total, next) => total + next)
.ToString();
Run Code Online (Sandbox Code Playgroud)
我正在使用EF Core 3.0.0。它显示这样的错误。
Processing of the LINQ expression 'Aggregate<TimeSpan, TimeSpan>(
source: Select<TaskEntity, TimeSpan>(
source: Where<TaskEntity>(
source: DbSet<TaskEntity>,
predicate: (x) => x.Project.CompanyId == (Unhandled parameter: __companyId_0) && x.Status == True),
selector: (e) => Parse(e.TimeClocked)),
seed: (Unhandled parameter: __p_1),
func: (total, next) => total + next)' by 'NavigationExpandingExpressionVisitor' failed. …Run Code Online (Sandbox Code Playgroud)