MonFralltar
New Member
I'm working on a project with a system that holds data and I'm thinking about using a data access approach to get data to hand it off to my components on the presentation side of things. I'm thinking of this as an N-tier architecture. Here's my thought:\[quote\] Presentation layer (WebForms and User Controls)\[code\] \/\[/code\] Data access layer (this is where my question is)\[code\] \/\[/code\] Business objects (a C# class for each entity in the system)\[code\] \/\[/code\] Existing APIs to get data from database (MS SQL-driven)\[/quote\]In my DAL, I want to use a particular API mechanism from the system to get the business objects so I can pass them to my presentation components. I am aware of the repository pattern where I create various utility repository classes to "get a bunch of the X business objects". E.g. say I have a business object called \[code\]Article\[/code\], I could have an \[code\]ArticleRepository\[/code\] and my "Article listing page" would call that repository and get me a collection of \[code\]Article\[/code\]. This is nice, but might be overkill at the DAL for me. Is there a name of doing something else like just having a \[code\]static GetAll()\[/code\] method on my business object? So isntead of:\[code\]var repo = new ArticleRepository();IEnumerable<Article> articles = repo.GetAll();\[/code\]I'm thinking something simple like this:\[code\]IEnumerable<Article> articles = Article.GetAll();\[/code\]Where the \[code\]Article\[/code\] class is both my business object with relevant properties and even helper methods, but also has a \[code\]static GetAll()\[/code\] method. Is there a name for this approach? Is it a bad idea to create this slimmed down pseudo-repository?I ask all this because simply put, I will have LOTS of repository classes to do this because I have lots of business objects, all with unique queries to get them from the system.