为一个属性设置多个值
我有两个类,您可以在下面看到:
public class Product
{
public int Id {get; set;}
public string Name {get; set;}
public decimal SuggestionPrice {get; set;}
public List<SaleOrder> SaleOrders {get; set;} = new List<SaleOrder>();
}
public class SaleOrder
{
public int Id {get; set;}
public List<Product> Products {get; set;} = new List<Product>();
}
如您所见,这两个类具有 Many-To-Many
RealationShip to everyother.in Product class
我有 我想在其中保存多个值 SuggestionPrice
属性,并且每个 SaleOrder 类
都有所不同。
例如,某人在一个 SaleOrder 中提供 1,000 美元,而其他人在另一个 SaleOrder 中针对相同产品提供 2,000 美元,以及我想要的无数其他建议将它们全部保存在数据库中。
问题是我不知道该怎么做?我怎么知道女巫 SuggestionPrice
是女巫 SaleOrder Class
的?
I have two class that you can see below:
public class Product
{
public int Id {get; set;}
public string Name {get; set;}
public decimal SuggestionPrice {get; set;}
public List<SaleOrder> SaleOrders {get; set;} = new List<SaleOrder>();
}
public class SaleOrder
{
public int Id {get; set;}
public List<Product> Products {get; set;} = new List<Product>();
}
as you can see,this two class have Many-To-Many
RealationShip to eachother.in Product class
i have SuggestionPrice
property that i want save multiple value
in it and it's difference for each SaleOrder Class
.
for example,Someone offers $ 1,000 in one SaleOrder and someone else offers $ 2,000 in another SaleOrder for same product and infinitely another suggestions that I want to save them all in database.
problem is i don't know how can i do this?how can i know witch SuggestionPrice
is for witch SaleOrder Class
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要保存在数据库中,您应该创建一个如下所示的 SuggestionPrice 表:
并将产品类更改为:
在 Product 和 SuggestionPrice 之间创建一对多关系。
To save in database You should create a SuggestionPrice table like this:
and change product class to this:
to create a one to many relation between Product and SuggestionPrice.