业务逻辑层、多表、关系
在业务逻辑中,我们将表映射到对象,并将该表的字段映射到属性。 在一对多关系中该怎么做?举个例子:我有表、产品和类别。 我需要拖动所有产品,而不是需要显示存储在类别表中的实际类别名称,而不是 Category_ID(产品表)。
Proal 的做法是什么?在类似的情况下?
In the business logic we map, Tables to Objects and fields of this table to properties.
What to do in one-to many relationship? Just an example: I have Table, Products and Categories.
I need to drag all products and instead of Category_ID (Products table) need to display actual Category name wich is stored in Category table.
What is propal way of doing it? In similar situations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在产品实体上拥有类别实体类型的属性。查看 EntitySpaces(.Net 的 ORM)文档中的链接以获取想法:
链接文本
另外,您可能想考虑使用 ORM。
You can have a property on the Products Entity that is of type Category Entity. Check this link out from the EntitySpaces (an ORM for .Net) documentation for ideas:
link text
Also, you may want to look into using an ORM.
使用 ORM(例如 LINQ to SQL 或 ADO.NET 实体框架)或强类型数据集。但是,如果您想对业务层进行自定义编码,您的 Category 类可能有一个 Products 集合属性,其中包含从数据库加载的那些产品,您可以推断出名称。
HTH。
Either use an ORM like LINQ to SQL or ADO.NET Entity Framework or strongly-typed datasets. But if you want to custom code your business layer, your Category class could have a Products collection property which contains those products, loaded from the DB, which you could infer the name.
HTH.