score:2
No, that's not weird, and in fact that is very similar to how i do it.
Only differences for me:
- I use
IQueryable<T>
instead ofIEnumerable<T>
(to get deferred exec) - I have a generic repository (
Repository<T>
):IQueryable<T> Find()
void Add(T)
- etc etc
This way, my repositories stay clean/simple.
So your BLL could be implemented like this:
public IEnumerable<Order> GetOrders(long CustomerID)
{
Repository<Order> orderRepository = new Repository<Order>(); // should use DI here, but i digress
return orderRepository
.Find() // no query executed...
.Where(o => o.CustomerID == CustomerID) // still nothing...
.ToList(); // query executed, with BL applied! cool!
}
Makes the BLL do the projection/work/logic. Repositories just handle persistence of T, doesn't care about the actual type, or any business logic.
That's how i do it anyway.
score:1
Consider that your data access layer could be providing services like:
- Create
- Update
- Delete
GetSingleCustomer()
CalculateUpperManagementTuesdayReport()
I wouldn't say it's terribly odd, but perhaps your DAL doesn't need to provide those services, as your application doesn't require them.
Having your filter/join/select in the BL, I'd prefer IQueryable<t>
instead of IEnumerable<T>
. This means that the execution of a given statement in the BL code doesn't happen until you call Single()
, First()
, ToList()
, Count()
, etc, etc within the BL code.
score:0
My question would be what would you lose if you merge the current BLL and the DAL? - they both seem to be dealing with bridging the gap from persisted data (DBs) to objects.. Seems like the simplest thing that would work. Another way of looking at it would be is change localized ? e.g. if there is a change in DAL layer, would that be isolated or would it ripple through into the upper layers (which is undesirable).
The BLL ideally should encapsulate the rules/workflows of your domain aka domain knowledge. e.g. if certain customers are treated differently. The DAL exists to transform your data from the persisted state into objects (or data structs to be consumed by higher layers) and vice versa. That's my understanding as of today...
Source: stackoverflow.com
Related Articles
- LINQ query methods in the data access layer(DAL)
- How To Create Generic Data Access Object (DAO) CRUD Methods with LINQ to SQL
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Use a linq query as microsoft local report Data Source (WinForms)
- How to access a particular data in LINQ query result?
- Using LINQ query result for data source for GridControl c#
- Linq query null check in data source
- Data binding access in xaml vs in code behind - Linq to XML?
- Return type for Linq query Joining two tables from a Data Access Layer
- Linq query to access data from xml
- c# Linq or code to extract groups from a single list of source data
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- Using a LINQ query to populate a combo box with data from an access database
- How can I bind a query with a join to a GridView, with a Linq datasource with a business layer and data access layer
- LINQ query code for complex merging of data
- Query Microsoft Access MDB Database using LINQ and C#
- Nested "from" LINQ query expressed with extension methods
- LINQ query — Data aggregation (group adjacent)
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- What is the difference between LINQ query expressions and extension methods
- Query data using "Contains" keyword in Dynamic Linq in C#
- Access all of the data after joining two tables and group them using linq
- LINQ to SQL - Compile error when extending data context with partial class and methods
- LINQ to SQL: Complicated query with aggregate data for a report from multiple tables for an ordering system
- LINQ - using a query expression to calculate data time difference
- LinQ query with multiple tables and extracting data
- LINQ Query to insert data into the database
- Best practices re: LINQ To SQL for data access
- How does linq actually execute the code to retrieve data from the data source?
- How to access oracle data using Linq through ADO.net?
- Linq count of records in a list
- linq select field type unknown
- How to read an uploaded CSV file in ASP.NET and skip the first line?
- How to tell if one Expression tree is a subset of another
- Composite group join
- Linq Results of Where to Object Collection
- Count numbers of repetitive words in a string without breaking order
- Using Linq to get a list of Ids as a List(Of String) in VB.NET
- Find a Non-Duplicate Row in DataTable
- Linq Query with using sum and order by
- Avoiding Redundancies in XML documents
- Linq Where clause with two conditions, not working
- take query from sql by LINQ
- LinqToTwitter List DMs since a specified date
- Entity Framework & Linq Orderby
- How to combine 2different IQueryable/List/Collection with same base class? LINQ Union and Covariance issues
- Linq Date Performance Death
- Using LINQ to Entities extension methods for more than one entity type
- Change the sequens of columns in datatable with linq
- Writing CSV to MemoryStream using LinqToCSV does not return any data