enter code here
Я хочу показать список AppPlatforms в модели, у меня есть 4 таблицы App, AppPlatforms, Reviews, AppsArtifacts, у которых есть отношения. Поэтому я хочу получить данные приложения, а также AppPlatforms (например, iOS и Android) этого приложения, а затем в AppPlatforms мне нужны коллекции обзоров и AppArtifacts.Как получить Список элементов в модели товаров с помощью Include
я использовал этот код, чтобы включить
, когда я использую этот
var app = dbContext.Apps
.Include("AppPlatforms.Reviews")
.Where(a => a.AppId == appId).ToList();
ИЛИ
var app = dbContext.Apps
.Include("AppPlatforms.Artifacts")
.Where(a => a.AppId == appId).ToList();
индивидуально он включен, но когда я использую этот
var app = dbContext.Apps
.Include("AppPlatforms.Reviews")
.Include("AppPlatforms.Artifacts")
.Where(a => a.AppId == appId).ToList();
тогда я иду t ошибка i.e InnerException = {«Неизвестный столбец« Extent1.AppId »в разделе« on »)
Вот мои таблицы.
public class App
{
[Key]
public int AppId { get; set; }
public string Name { get; set; }
public bool? IsActivated { get; set; }
public bool? Status { get; set; }
public string UserId { get; set; }
public DateTime UploadedDate { get; set; }
[ForeignKey("UserId")]
public virtual IdentityUser IdentityUser { get; set; }
public int? CategoryId { get; set; }
[ForeignKey("CategoryId")]
public virtual Category Category { get; set; }
public int? SubCategoryId { get; set; }
[ForeignKey("SubCategoryId")]
public virtual SubCategory SubCategories { get; set; }
public virtual ICollection<AppPlatform> AppPlatforms { get; set; }
}
public class AppPlatform
{
[Key]
public int AppsPlatformId { get; set; }
public string AlternativeName { get; set; }
public string Version { get; set; }
public string DownloadLink { get; set; }
public DateTime LastUpdated { get; set; }
public DateTime? ReleaseDate { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
public float FileSize { get; set; }
[DefaultValue(0)]
public int AppId { get; set; }
[ForeignKey("AppId")]
public virtual App App { get; set; }
public int PlatformId { get; set; }
[ForeignKey("PlatformId")]
public virtual Platform Platforms { get; set; }
public virtual ICollection<Review> Reviews { get; set; }
public virtual ICollection<AppsArtifact> Artifacts { get; set; }
}
public class AppsArtifact
{
[Key]
public int Id { get; set; }
public int AppsPlatformID { get; set; }
[ForeignKey("AppsPlatformID")]
public virtual AppPlatform AppPlatform { get; set; }
public int ArtifactId { get; set; }
[ForeignKey("ArtifactId")]
public virtual Artifact Artifact { get; set; }
public AppArtifactType Type { get; set; }
}
public class Review
{
[Key]
public int ReviewId { get; set; }
public string Description { get; set; }
public int Value { get; set; }
public int Risk { get; set; }
public ReviewStatus Status { get; set; }
public DateTime ReviewDate { get; set; }
public int? AppPlatformId { get; set; }
[ForeignKey("AppPlatformId")]
public virtual AppPlatform AppPlatform { get; set; }
public string ReviewerId { get; set; }
[ForeignKey("ReviewerId")]
public virtual IdentityUser IdentityUser { get; set; }
public int LevelId { get; set; }
[DefaultValue(1)]
public bool IsActive { get; set; }
[ForeignKey("LevelId")]
public virtual Level Levels { get; set; }
}
отношения отображаются с помощью 'ForeignKey' атрибут –
, возможно, не будет достаточно – J4ime