我正在尝试获取在其个人资料中具有博客 ID 的用户的用户名。
此代码返回所有博客并将其放入列表中:
Dim blogs = db.Blogs.Include(Function(b) b.Company)
Return View(blogs.ToList())
我想在列表中包含博客所属的用户名。该数据保存在配置文件实体中(在名为“BlogId”的字段中)。
这是配置文件实体:
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Public Class UserProfile
Public Property UserProfileId() As Integer
Public Property UserId() As Guid
Public Property CompanyId() As Integer
Public Property BlogId() As Integer
Public Property IsCompanyOwner As Boolean
Public Property IsBlogOwner As Boolean
End Class
Public Class UserProfileDbContext
Inherits DbContext
Public Property UserProfiles As DbSet(Of UserProfile)
End Class
如何将用户名放入 ToList() 以在我的视图中显示?
谢谢。