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

随心笔谈3年前发布 admin
207 0 0

文章摘要

这篇文章介绍了三个实体类:`User`、`Role` 和 `UserDto`。`User` 和 `Role` 分别用于表示用户和角色,包含字段如 `UserId`、`UserName`、`Password`、`IsDelete`、`CreateTime`、`RoleId` 和 `RoleName`。`UserDto` 则是 `User` 的 DTO(数据传输对象)版本,用于在其他系统中传输数据,不用于直接存储在 MongoDB 中。文章重点描述了这些实体类的字段结构及其用途。

/// <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; }
}

© 版权声明

相关文章