简体   繁体   中英

c# N-tier architecture - should the BL or presentation layer know about custom types in DataLayer

I'm creating a 3-tier solution comprising of the box standard projects: DAL, BLL, Presentation layer.

There are some custom types in my DAL such as:

public class Clients 
{
public int Id {get;set}
public string Firstname {get;set;}
public string Surname {get;set;
} 

What is the best approach to push this custom type up the stack to the presentation layer. Is it common practice for the BL and presentation to reference models from my DAL? Or should I look at generic interfaces so that the BLL can accept/consume a List <T> for example?

After a bit of digging it looks like DTOs are my best route. So I'll create a new project to hold custom object types aka business objects. This project will in turn be referenced by my DAL, BLL and presentation layer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM