i've got a database with a table named PropertyValues where i store every value i need to describe some properties of my database table rows.
For example, table Products which looks like this :
OrderID //Products table is related with Order table
ProductType_ID // ID of PropertyValues table which describes product type (food, parfume, chemicals)
ProductCountry_ID // ID of PropertyValues table which links to country where product came from ProductStatusID //also ID of PropertyValues table which contains product status(availible, not availible)
with such database model, to get order and all it's products with their type, country and status i'll have to write something like this :
var orders = from o in dbEntities.Order.Include("Products.ProductType") .Include("Products.ProductCountry") .Include("Products.ProductStatus") select o;
and the question is :)
can it be done automatically ( so all related entities will be included )
or maybe there is better approach ?
Thank You !
I think what you are looking for is either "Lazy Loading" or "Eager Loading" as Alex James pointed out.
This blog post explains that "Lazy Loading" is to be implemented in version 4.0 of the Entity Framework.
It can be done automatically, Google "Entity Framework lazy loading" to go about setting it up.