Link to home
Start Free TrialLog in
Avatar of ullfindsmit
ullfindsmitFlag for United States of America

asked on

Linq Composite Object Return From Logic

I am trying to break down the architecture into three independent layers Data/Logic and App (Web/Service/Application/WS)

As posted on my previous question https://www.experts-exchange.com/questions/25355958/Linq-Error.html

I have now set up my objects in ABC.Data and my DataContext in ABC.Logic

However, what I am running in to is that I can only return objects in my ABC.Data library.

How do I handle selecting Customer Information as well as other columns relevant to the query and returning it to the APP layer without having to create classes?

Example:
// I CANT RETURN A LIST OF CUSTOMER AND STATE INFO LIKE SPECIFIED IN THE QUERY
public List<Test1.Logic.Customer> GetCustomerByStateName(String StateName)
        {
            Test1.Logic.DataClasses1DataContext db = this;
            return (
                    from c in db.Customers
                    join cl in db.CustomerLocations on c.CustomerId equals cl.CustomerId
                    where cl.USState.USStateAbbr == StateName
                    select c, cl
                ).ToList<Test1.Logic.Customer>();
        }



Hope this explains what I am trying to do.
Thanks
Smit.
ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got around architectural problems like this by utilizing transfer objects. These are simple classes tailer made to meet the needs of the business logic. It's part of the DAO pattern design, which you can read about here:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
Avatar of ullfindsmit

ASKER

DaTribe I ended up extending all the data objects in my logic library so I can add additional fields without having to read create the base fields from DB.

Labelsoft, what you are recommending is what we are trying to get away from. The system is overengineered for what it is needed for. The amount of time needed to make a simple change is significantly higher in creating these layers that in our case dont really serve a purpose.

Thank you for your time.