我第一次和EF一起工作,所以我不知道是这样的情况,还是我有严重的性能问题。
我有以下情况:
大数据对象 - 我太担心了
贝娄是我有的类。项目是这里的主要对象。所以当我从数据库中提取项目列表时,我会获得例如1000个项目。现在这个项目中的每一个都有数据提交的所有属性。城市包含国家,国家包含城市的列表,用户已创建项目的列表,每个项目的所有数据,城市,城市有国家,国家的城市名单等等...
也许我担心得太多,不知道这个对象是否应该包含所有这些数据,这是否会导致性能问题,或者我在这里做错了什么?
public abstract class Item
{
[Key]
public int ItemId { get; set; }
public int ItemTypeId { get; set; }
public Guid UserId { get; set; }
public DateTime CreatedOnDate { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public int? MediaId { get; set; }
public int CityId { get; set; }
public virtual City City { get; set; }
public virtual User User { get; set; }
public virtual ICollection<ItemInBoard> ItemsInBoard { get; set; }
public virtual ICollection<Like> Likes { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
public class City
{
public int CityId { get; set; }
public string Name { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
public int CountryId { get; set; }
public virtual Country Country { get; set; }
}
public class Country
{
public int CountryId { get; set; }
public string Name { get; set; }
public string CountryCode { get; set; }
public virtual ICollection<City> Cities { get; set; }
}
public class User
{
public Guid UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool Gender { get; set; }
public DateTime? BirthDay { get; set; }
public string AboutMe { get; set; }
public int? MediaId { get; set; }
public int CityId { get; set; }
public virtual City City { get; set; }
public virtual ICollection<Item> Items { get; set; }
public virtual ICollection<Board> Boards { get; set; }
public virtual ICollection<Like> Likes { get; set; }
}
桌面或网络应用程序? – walther
Web应用程序 – 1110