N
Narshe
I've been struggling with this for a while.
I have a business entity Employee that has a Company entity attached
to it.
Ex:
public class Compay{ // blah }
public class Employee
{
private Company _company;
public Company Company{ // get/set }
}
I'm looking for a good way to get the data for the Company reference.
Right now, the company info is got when needed, so there is a separate
query for the company. This presents a problem when you have a list
of Employees. You get 10 employees with one query, but then there are
10 more queries, one for each Company. This adds up if you have more
references on the Employee object than just Company, and if Company
has reference objects on it.
I know one way to solve this is to use a builder. So, you get your
list of Employees, pass it to a builder, the builder does a query to
get the Companies for those Employees, and you loop through and match
them up. I've found this to not work too well, which could be the way
I implemented it.
When LINQ in .NET 3.5 is released, this should solve the issue, but
that's not for a while yet and I still would like to know of a good
way to do it that will work for all languages, not just .NET 3.5.
Any suggestions?
Thanks.
I have a business entity Employee that has a Company entity attached
to it.
Ex:
public class Compay{ // blah }
public class Employee
{
private Company _company;
public Company Company{ // get/set }
}
I'm looking for a good way to get the data for the Company reference.
Right now, the company info is got when needed, so there is a separate
query for the company. This presents a problem when you have a list
of Employees. You get 10 employees with one query, but then there are
10 more queries, one for each Company. This adds up if you have more
references on the Employee object than just Company, and if Company
has reference objects on it.
I know one way to solve this is to use a builder. So, you get your
list of Employees, pass it to a builder, the builder does a query to
get the Companies for those Employees, and you loop through and match
them up. I've found this to not work too well, which could be the way
I implemented it.
When LINQ in .NET 3.5 is released, this should solve the issue, but
that's not for a while yet and I still would like to know of a good
way to do it that will work for all languages, not just .NET 3.5.
Any suggestions?
Thanks.