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: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...
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.
Source: stackoverflow.com
Related Query
- LINQ query methods in the data access layer(DAL)
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- What is the difference between LINQ query expressions and extension methods
- How To Create Generic Data Access Object (DAO) CRUD Methods with LINQ to SQL
- Access all of the data after joining two tables and group them using linq
- LINQ Query to insert data into the database
- How does linq actually execute the code to retrieve data from the data source?
- What is the return type for a anonymous linq query select? What is the best way to send this data back?
- How can I write the following code more elegantly using LINQ query syntax?
- How do I write a LINQ query that inverts the grouping of a hierarchical data source?
- Use a linq query as microsoft local report Data Source (WinForms)
- Determine the source DataContext for a Linq to Sql query
- How to access a particular data in LINQ query result?
- What are the major differences between Data Access Application Block, NHibernate, ADO.NET Entity Framework and LINQ to SQL?
- Project only the most current data into a linq query
- Using LINQ query result for data source for GridControl c#
- How can I access the group of a linq group-by query from a nested repeater control?
- How to swap the data source associated with a Linq query?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How do I determine the source of unpredictable LINQ query results?
- Can I use a LINQ IEnumerable result as the data source for a Gtk.TreeView?
- LINQ - database query using "into", how do I reference data prior to "into" in the select clause?
- LINQ query in C# using string on the fly to ORDER data
- LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'
- Reduce the line of code for this LINQ query
- Linq query null check in data source
- Can I Use The Same Linq Code to Query for Different Conditions?
- Workaround to take invalid LINQ methods out of the query in generic method
- LINQ - changing Data Source (and the LINQ Provider) at runtime in C#
- Data binding access in xaml vs in code behind - Linq to XML?
More Query from same tag
- MVC C# Select Where
- Return related data from dB c#
- Get List of Records that do not exist in another list - Linq
- C# merge multiple lists based on timestamp
- Linq Sql Int null equal to null. Not returning rows
- Which is faster? Loop over object properties or linq query?
- Multiple filters on a collection using LINQ
- Linq nested Where() clause
- Entity framework: add info to relational tables but keep EF object format
- Dynamic LINQ Select method "selector" argument
- Mock in unit test returns null at LINQ.Where
- NHibernate left join with linq
- Few database in one dbml?
- Passing a List of values and rerturning a Dictionary for their associated results
- Understanding explicit vs implicit variable declaration in LINQ
- Unbind parameter
- Help me make this LINQ query faster please?
- Using Linq ConvertAll to create a backup of a list before altering the list
- How can I split a MultiSelectList into n number of items and wrap each partitioned group of items with markup
- Save picture Path with LINQ in SQL
- Why does SortedList in C# have no Find method?
- C# LINQ Lambda query with select, Where, Count and Distinct
- Searching data in a list using linq
- What does ParallelQuerys Count count?
- Build dynamic linq to Sql lambda expression
- Linq-to-Entities working with One-to-Many Relationship and Sorting
- .net Core 3.1 Linq Expression "...could not be translated." Exception
- How can I call a stored procedure with INSERT using LINQ?
- Why the text of combobox show the items with property name?
- query an IList type object using Any element