正文

.NET?Core利用BsonDocumentProjectionDefinition和Lookup进行?join?关联查询(推荐)(.net core 调用内部方法)一看就会

文章摘要

本文介绍了三个实体类:`User`、`Role` 和 `UserDto`。`User` 类包含用户信息,包括唯一标识符 (`UserId`),用户名 (`UserName`),密码 (`Password`),删除标记 (`IsDelete`) 和创建时间 (`CreateTime`),以及角色标识 (`RoleId`)。`Role` 类记录角色信息,包括唯一标识符 (`RoleId`) 和名称 (`RoleName`),以及创建时间 (`CreateTime`)。`UserDto` 类是用户信息的 DTO(数据传输对象),包含 `UserId`、`UserName`、`RoleId` 和 `RoleName`,以及创建时间 (`CreateTime`)。这些实体类的设计为后续的 MongoDB 数据建模和 DTO 转换提供了基础。

/// <summary> /// 用户实体(Collection) /// </summary> public class User { public Guid UserId { get; set; } public string UserName { get; set; } public string Password { get; set; } public bool IsDelete { get; set; } public DateTime CreateTime { get; set; } public Guid RoleId { get; set; } } /// <summary> /// 角色实体(Collection) /// </summary> public class Role { public Guid RoleId { get; set; } public string RoleName { get; set; } public DateTime CreateTime { get; set; } } /// <summary> /// 构建用户Dto(不在Mongo创建Collection) /// </summary> public class UserDto { public Guid UserId { get; set; } public string UserName { get; set; } public DateTime CreateTime { get; set; } public Guid RoleId { get; set; } public string RoleName { get; set; } }