我是相当新的ORMs,ADO.NET EF特别是。我正在使用这种Code First方法。我的有这两张表DB:
Material:
public class Material
{
[Required]
[MaxLength(10)]
public string Code { get; set; }
[MaxLength(40)]
public string Color { get; set; }
[MaxLength(40)]
public string Description { get; set; }
[MaxLength(255)]
public string Picture { get; set; }
public long MaterialTypeId { get; set; }
public virtual MaterialType MaterialType { get; set; }
}
和MaterialType:
public class MaterialType
{
[MaxLength(40)]
public string MatType { get; set; }
public virtual ICollection<Material> Materials { get; set; }
}
而且我有一个DataGridView填充所有信息的地方,Material除了MatTypewhich isLeather和Plastic类似的东西,我必须从桌子上拿走MaterialType。这是FK迄今为止唯一的一个,所以我SELECT *..之前和现在的用户,当涉及到它时,我不知道如何构建我的代码/查询,所以我可以DataGridView用第二个表中的信息填充。在DataGridView我有MaterialTypeId隐藏的列。