.NET?Core利用BsonDocumentProjectionDefinition和Lookup进行?join?关联查询(推荐)(.net core 调用内部方法)一看就会
/// 用户实体(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; }
}