有关业务逻辑层的帮助.请! [英] Help with Business Logic Layer. PLEASE!

查看:81
本文介绍了有关业务逻辑层的帮助.请!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我.我正在开发一个具有三层(VS 2008中的项目)的应用程序-DAL,BLL和UI. DAL在我的表中有两个类:Customers.客户数据访问类对数据库执行CRUD,并填充客户数据对象类,该类仅由具有get/set的属性和用于对其初始化的构造方法组成.我创建了数据对象以使用它将查询结果传递回BLL.现在,这两个类都在DAL项目中.

BLL(项目)引用DAL.我有以下问题:

1.如何为Customer对象创建BLL类,该类实现用于Insterts,Update和Deletes的业务逻辑以及检查字段的值以符合业务需求?

2.客户的BLL等级;在能够执行业务规则之前,它还必须创建Customer对象的所有属性,以及在Customer Data Access Layer中创建的Insert,Update和Delete方法吗?

3. BLL如何提取客户数据对象的状态,以便UI可以使用它,例如,当UI希望查询数据库时?我不希望UI绕过BLL,因为我想在其中放置授权规则.

请帮助我,一些示例代码将不胜感激,因为我从未在这种类型的分层体系结构上工作过.
谢谢.

Melton

Please help me. I am working on an application with three layers (projects in VS 2008) - DAL, BLL and UI. The DAL has two classes for my table, Customers. The Customer Data Access Class performs CRUD against the database, and populates the Customer Data Object Class which consists only of properties with get/set and Constructors for initializing it. I created the Data Object to use it to pass query results back to the BLL. Now both of these classes are in the DAL project.

The BLL (project) references the DAL. I have these question:

1. How do i create a BLL class for the Customer object that implements business logic for Insterts, Updates and Deletes as well as check the values of the fields to conform to business requirements?

2. The customer BLL class; must it also create all the properties for the Customer objects, as well as the Insert, Update and Delete methods as created in the Customer Data Access Layer before being able to enforce business rules?

3. How does the BLL pull out the state of the Customer Data Objectt so that the UI can consume it, such as when the UI desires to query the database? I do not want the UI to circumvent the BLL, as i want to place authorization rules there, among other things.

Please help me, Some sample code will be greatly appreciated, as i have never worked on this type of layered architecture.
Thank you.

Melton

推荐答案

听起来像是您阅读杂志上的文章,但并不太了解您在做什么.

1-您编写代码以调用DAL并检查返回值.

2-我不知道.我希望Customer类将具有一个构造函数,该构造函数创建一个新对象并将其存储在DB中.但是,您的业务需求取决于您

3-如果UI想要的只是从DB取回对象集合,则UI可以直接调用DAL.

Sounds like you read a magazine article but don''t really understand what you''re doing.

1 - you write code to call the DAL and check the return values.

2 - I don''t know. I would expect that the Customer class would have a constructor that creates a new object and stores it in the DB. But, your business needs are up to you

3 - The UI can call the DAL directly if all it wants is to get back a collection of objects from the DB.

coommark写道:
coommark wrote:

因为我从未在这种类型的分层体系结构上工作过.

as i have never worked on this type of layered architecture.



好吧,这确实是常识.确保各层之间没有过度依赖,并将所有数据访问保留在DAL中,并将所有业务逻辑保留在BLL中.



Well, it''s really common sense. Make sure the layers do not rely on each other overly, and keep all data access in the DAL, and all business logic in the BLL.


这篇关于有关业务逻辑层的帮助.请!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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