Question on the implementation of the layered design

Aug 10, 2008 at 7:54 PM
As per "Pattern & Practices" document, Business Layer sits above Data Access Layer, my understanding on the layering is that Business Layer cannot visit and bring data straight from database without going through Data Access Layer.

As currently implemented, Business Entity (ExpenseSample.Business.Entities) is part of Business layer and directly communicates with database using LINQ to SQL. All Data access classes visits the database through these class, which is confusing. ExpenseSample.Business.Entities has been placed here to keep Business Entity in Business Layer as suggested in Pattern and Practice guideline. This defeats the main purpose of layering.

Any thoughts? Why this has been done this way.

Thank you very much for your attention.
Coordinator
Aug 13, 2008 at 10:45 AM
Hi Jxs,

You brought up a good point. I guessed I didn't see it in that perspective when I built the sample. I had made the Data Access Components to continue to establish connection to the database and manipulate the CRUD for the entities but I missed out that the actual code to persist the entities lies within the ExpenseDBDataContext class. This will allow developers to get access to LINQ features outside other layers.

LINQ to SQL is an Object-Relational Mapper and it has the characteristics to communicate with the database directly. This is by-design. The generated code is produced by the Visual Studio designer itself. I guessed the key to confusion is perhaps in the DataContext class. If we were to separate that and put it inside the Data Access Component, would that make more sense?

Do share your thoughts.

Thank you

Best Regards,
Serena



Oct 3, 2008 at 6:34 AM
Edited Oct 3, 2008 at 6:38 AM
Hi Firedancer,

Why the choice of LINQ to SQL? My personal thought is Nhibernate or ADO.NET Entity Framework is  a better choice for Data Access layer.

Maybe you can share your thoughts on the choice that you have made. Just my 2 cents :-P


Coordinator
Oct 10, 2008 at 12:25 AM
Hi Henry,

LINQ-to-SQL was the only thing available in RTM when I was upgrading the sample. I guessed now that ADO.NET EF is released in SP1, I may look at it and eventually use it as part of my sample. :)
Oct 10, 2008 at 1:28 AM
That would be a great idea.

----- Original Message ----
From: firedancer
To: shaikhj@yahoo.com
Sent: Thursday, October 9, 2008 5:25:36 PM
Subject: Re: Question on the implementation of the layered design [LayerSample:33258]

From: firedancer

Hi Henry,

LINQ-to-SQL was the only thing available in RTM when I was upgrading the sample. I guessed now that ADO.NET EF is released in SP1, I may look at it and eventually use it as part of my sample. :)

Oct 10, 2008 at 7:04 AM
Hi firedancer,

It is good to know that you will be implementing ADO.NET EF into the project. I would also suggest using IoC container like Spring, Windsor or Unity to improve the extensibility of the layer.Another suggestion will be to apply Repository Pattern for the Data Access layer :)



On Fri, Oct 10, 2008 at 9:29 AM, JXS <notifications@codeplex.com> wrote:

From: JXS

That would be a great idea.

----- Original Message ----
From: firedancer
To: [email removed]
Sent: Thursday, October 9, 2008 5:25:36 PM
Subject: Re: Question on the implementation of the layered design [LayerSample:33258]

From: firedancer

Hi Henry,

LINQ-to-SQL was the only thing available in RTM when I was upgrading the sample. I guessed now that ADO.NET EF is released in SP1, I may look at it and eventually use it as part of my sample. :)

Read the full discussion online.

To add a post to this discussion, reply to this email (LayerSample@discussions.codeplex.com)

To start a new discussion for this project, email LayerSample@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Hendry Wijaya