这是我的类属性:
public int ProductId { get; set; }
public string Name { get; set; }
public DateTime Creation { get; set; }
public int BrandId { get; set; }
public virtual Brand Brand { get; set; }
public int CreatedBy { get; set; }
public decimal Price { get; set;
public string Description { get; set; }
public string Properties { get; set; }
public bool OnFrontPage { get; set; }
public int StockCount { get; set; }
public decimal MarketPrice { get; set; }
public int CurrencyId { get; set; }
public virtual Currency Currency { get; set; }
public int TaxRate { get; set; }
public bool IsNewProduct { get; set; }
public bool IsActive { get; set; }
public string MetaDescription { get; set; }
public string MetaKeyWord { get; set; }
public int UnitId { get; set; }
public virtual Unit Unit { get; set; }
public int PointValue { get; set; }
public string RelatedProductIds { get; set; }
public int MaxSaleCount { get; set; }
public int ProductGroupId { get; set; }
public virtual ProductGroup ProductGroup { get; set; }
public virtual List<ProductCategory> ProductCategories { get; set; }
public virtual List<ProductType> ProductTypes { get; set; }
public virtual List<ProductImage> ProductImages { get; set; }
public virtual List<Promotion> Promotions { get; set; }
public int SaleCount { get; set; }
public virtual List<ProductChance> ProductChances { get; set; }
public string ProductCode { get; set; }
这是由上下文创建的 sql 查询。上下文添加 [Category_CategoryId] 列但是我在我的班级或我的数据库表中没有任何关于类别的信息
SELECT
[Extent1].[ProductId] AS [ProductId],
[Extent1].[Name] AS [Name],
[Extent1].[Creation] AS [Creation],
[Extent1].[BrandId] AS [BrandId],
[Extent1].[CreatedBy] AS [CreatedBy],
[Extent1].[Price] AS [Price],
[Extent1].[Description] AS [Description],
[Extent1].[Properties] AS [Properties],
[Extent1].[OnFrontPage] AS [OnFrontPage],
[Extent1].[StockCount] AS [StockCount],
[Extent1].[MarketPrice] AS [MarketPrice],
[Extent1].[CurrencyId] AS [CurrencyId],
[Extent1].[TaxRate] AS [TaxRate],
[Extent1].[IsNewProduct] AS [IsNewProduct],
[Extent1].[IsActive] AS [IsActive],
[Extent1].[MetaDescription] AS [MetaDescription],
[Extent1].[MetaKeyWord] AS [MetaKeyWord],
[Extent1].[UnitId] AS [UnitId],
[Extent1].[PointValue] AS [PointValue],
[Extent1].[RelatedProductIds] AS [RelatedProductIds],
[Extent1].[MaxSaleCount] AS [MaxSaleCount],
[Extent1].[ProductGroupId] AS [ProductGroupId],
[Extent1].[SaleCount] AS [SaleCount],
[Extent1].[ProductCode] AS [ProductCode],
[Extent1].[Category_CategoryId] AS [Category_CategoryId]
FROM [dbo].[Product] AS [Extent1]}
类别:
public int CategoryId { get; set; }
public string Name { get; set; }
public string LinkText { get; set; }
public int? ParentId { get; set; }
public string Description { get; set; }
public string ImageUrl { get; set; }
public bool IsActive { get; set; }
public virtual List<Product> Products { get; set; }
public DateTime Creation { get; set; }
public int CreatedBy { get; set; }
public bool IsParentCategory { get; set; }