ASP.Net多层应用程序 [英] ASP.Net multitier applications
问题描述
我知道这是一个简单的问题,我还是个新手。
我想通过刻录2个表来返回数据。 Products表和ProductCategory表。
在我的DAL中,我有一个产品类和一个ProductCategory类。那么我是否必须创建一个具有Products类和Product Category类属性的新类?难道没有其他有效的方法可以做到这一点吗?
我现在在网上搜了一整天,但我找不到答案。如果你能提供一些帮助我会很高兴吗?
I know this is a simple question and I am yet a newbie.
I want to return data by joning 2 tables. "Products" table and "ProductCategory" Table.
In my DAL I have a "Products" class and also a "ProductCategory" class. So do I have to create a new class that has both properties of the Products class and Product Category class? Isn''t there any other efficient way to do that?
I searched the net for a whole day now but i couldn''t find an answer. I would be glad if you can provide some help?
推荐答案
为什么这么复杂?你可以很容易地用两张桌子限制。
据我所知,每件产品都有它自己的产品类别,不是吗?
In因此,您必须向您的'ProductCategory注入额外的属性,例如List< product>产品< / product>
。
否则,如果ProductCategory
扮演2个表之间的链接表角色产品
和类别
,我的回答是YES,你需要创建新的DTO
将由数据组成的类。
Why so complicated ?? You can easily be bounded only with 2 tables.
As far as i understood every products has it''s own Product category, doesn''t it??
In case of YES, accordingly you must inject additional property to your''s ProductCategory likeList<product> Products</product>
.
Otherwise, in case whereProductCategory
play role of link table between 2 tablesProducts
andCategories
, My answer will be YES , you need to create newDTO
class which will be consists of data.
这篇关于ASP.Net多层应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!