【问题标题】:How to add additional field in nopcommerce 4.3如何在 nopcommerce 4.3 中添加附加字段
【发布时间】:2020-06-26 04:19:03
【问题描述】:

我想在域(Nop.Core => Domain)中添加不想包含在 nopcommerce 4.3 的表字段中的附加字段。实际上,我想要这个是因为我想在服务查询中从不同的表中获取数据。

这是我的代码:

protected virtual IQueryable<CustomerWastage> GetCustomerWastageQuery(int customerId)
{
    var query = (from customerWastage in _customerWastageRepository.Table
                 join product in _productMasterRepository.Table on customerWastage.ProductID equals product.Id
                 join carat in _caratMasterRepository.Table on customerWastage.CaratID equals carat.Id
                 where customerWastage.CustomerID ==   customerId                
                select new CustomerWastage() { Wastage = customerWastage.Wastage, ProductName = product.Name,  
                Carat = carat.Carat, CustomerID = customerWastage.CustomerID });

    return query;
}

这里 CustomerWastage 是一个域名,我想在其中添加其他字段,即

public string productname {get; set;} 
public string Carat {get; set;}

但不想映射到表格中。

【问题讨论】:

    标签: asp.net-mvc linq join nopcommerce


    【解决方案1】:

    我不太确定这是否能回答您的问题,但您可以使用 [NotMapped] 属性来指定不将类或属性映射到数据库。

    例子:

    公共字符串产品名称 {get;放;}
    公共字符串克拉{get;放;}
    
    [未映射]
    公共字符串 PropertyName { 获取;放; }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-05
      • 2014-04-04
      • 1970-01-01
      • 2020-05-29
      • 1970-01-01
      相关资源
      最近更新 更多