You can pass in queries, depending on what your query is returning, you just have to adjust your method, most of the time is an IEnumerable<type_of_object>,
Main Topics
Browse All TopicsI am not quite sure if this can be done and likewise not quite sure that it should be done, given the DataContext likes to work atomically.
I have a data access layer class that I will use LINQ to SQL to query my SQL 2005 database, so the code looks something like this:
//attempt to use LiNQ here
using (Outbound.dcCaseDataContex
{
var query = from cases in db.tblCases select cases;
//--> Call method here pass in query
}
I want to call a method and pass in the query the method will do some more work with regards to mapping and other business processes. My thought is the method might look like this:
public IQueryable<T> SomeMethod<T>(IQueryable<T
{
//Do some work
return dbSupportCases;
}
My main worry here is with the DataContext object. As well as proper design. The reason I need to pass in the query to another class is I have a business layer that needs to perform some mapping and I want to ensure separation of concerns.
Any guidence would be appreciated I have looked at a few blog sites such as http://www.west-wind.com/W
Thank you
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can pass in queries, depending on what your query is returning, you just have to adjust your method, most of the time is an IEnumerable<type_of_object>,
Thank you, daryal was right and in fact that is what I am doing I have a business layer talking to a data access layer all of the actual data and connection handling is occuring at the lowest layer.
Taking naspinski's suggestion in the business layer I have methods such as getcustomers, which inside is performing a LINQ query.
Thank you again.
Business Accounts
Answer for Membership
by: daryalPosted on 2009-09-25 at 23:21:54ID: 25428941
Hello,
In my opinion, what you are trying to do is against seperation of layers. You should complete all db related jobs in data access layer, and just send the data to business layer for processing. If you are sending something that will not be directly used in business layer, it is not a good practice.
I can not think about a good practice in where you need your db query in business layer, maybe you should check your design.