具有自定义对象的体系结构BLL [英] Architecture BLL with custom objects

查看:121
本文介绍了具有自定义对象的体系结构BLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用ASP.NET开发网站.
我创建了一个DAL类库项目,一个BLL类库项目和实际的ASP.NET Web应用程序项目.
从ASP.NET Web应用程序的目的来看,我添加了对BLL项目的引用.
在Bll项目中,我创建了映射每个数据库表的类.这些类中的任何一个都将在DAL中调用一个通用方法,该方法将返回IList< T>.其中T可以是一个类.
因此,如果我想从数据库中获取所有订单,则可以像这样在DAL中调用一个方法:

Hi,
I am developing a website with ASP.NET.
I have created a DAL class library project, a BLL class library project and the actual ASP.NET web application project.
From the ASP.NET web application prject I added a reference to the BLL project.
In the Bll project I created classes that map each database table. Any of these classes will call a generic method in the DAL that will return IList<T> where T can be a class.
So if I want to get all the orders from the database, I call a method in the DAL like this:

List<Order> orderList = DAL.GetAll<Order>("select * from sqlOrder");


问题是:

如果我想获取包含3个不同表(因此有3个联接)中数据的select语句的结果,我将无法再使用通用方法,因为在运行sql语句后返回的原始数据集无法转换为任何一个数据课.

最后,我还应该提到由于没有使用LINQ/NHIBERNATE或任何其他ORM工具的经验,所以我倾向于使用.NET Framework 2.0构建该系统,但是欢迎任何想法.

预先感谢,

Valentin.


The problem is:

If I want to get the results of a select statement which contains data from 3 different tables(therefore having 3 joins), I cannot use the generic method anymore because the raw dataset returned after running the sql statement can not be converted to any one single class.

In the end I should also mention that I preffer to build this system using .NET Framework 2.0 since I have no experience with LINQ/NHIBERNATE or any other ORM tools, but any ideas are welcomed.

Thanks in advance,

Valentin.

推荐答案

我也不同意直接在BLL中使用sql从DAL获取数据.我建议使用Provider模型在DAL本身中编写这些通用方法,然后将结果放入经过适当设计的BLL对象中.

您可以从此链接获取有关提供商模型的更多信息

http://dotnetslackers.com/articles/designpatterns/HowToWriteAProviderModel.aspx http://www.15seconds.com/issue/030317.htm
I also donot agree using a sql directly in BLL to get the data from DAL. I would suggest using a Provider model for write these generic methods in DAL itself and then get the results into suitably designed BLL objects.

you can get more info on provider model from this link

http://dotnetslackers.com/articles/designpatterns/HowToWriteAProviderModel.aspx

http://www.15seconds.com/issue/030317.htm

Hope this helps...


尝试 ADO.Net实体框架 [^ ]
-NDK
Try ADO.Net Entity Framework[^]
-NDK


嗯,我不同意在层之间传递SQL ...它仅属于DAL,因此我强烈建议您研究一种将其抽象化的技术(例如作为SubSonic).

但是,使用这种方法时,您将需要为返回的每种列组合创建一个附加的DTO对象.

如果您不太喜欢强类型方法,则还可以实现一个返回DataRows/DataTables的集合.
Well, I can''t aggree with passing SQL between layers...it belongs in the DAL only and I would strongly suggest you investigate a technology to abstract it away (such as SubSonic).

But, with the approach your using you will need to create an addditional DTO object for each combination of columns that your returning.

If you''re not too attached to the strongly typed approach you could also implement a set that returns DataRows/DataTables.


这篇关于具有自定义对象的体系结构BLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆