Scenario: I have a scenario with a Presentation layer (ASP.NET), Busi开发者_Go百科ness Logic Layer (dll) and Data Layer(dll) in the latter there is a LinqTOSQL DataContext file (dbml) which holds tables and stored proc for a particular database. The linking between projects are:
Dependencies: Business Logic Layer has a reference for Data Layer Presentation Layer has a reference for Business Logic Layer
My Problem: The problem is that I have cases when I need to return an object of a table type corresponding to the datacontext, but since the Presentation Layer does not has a reference to the Data Layer I can't use the table object...Is it good practice to reference the Data Layer directly in the Presentation Layer? Or could someone guide me to the best way how I could achieve the Tables from the Presentation Layer
Instead of having the business logic layer return a System.Data.Linq.Table<TEntity>
to the presentation layer, have it return a System.Collections.Generic.IEnumerable<TEntity>
via implicit cast, or a System.Collections.Generic.IList<TEntity>
by calling ToList()
on the table.
It sounds like the objects defined in your dbml file are already in your domain namespace, so this way you don't have to reference System.Data.Linq
in your presentation layer.
精彩评论