I am just getting started with Entity Framework. The problem i face is since it is an ORM it models everything as real world entities. Hence, if i fetch a parent record it's child records are fetched automatically. If i have 1000's of child records all of them get fetched even though i may not need them currently. This i think is very inefficient.
You would argue to use Lazy Loading in Linq and thus solve problem so that sql doesn't get sent to the SQL Server until it is accessed. But what if i am working in a web service or WCF based environment. In web services we see request response model. And as i know we can't use Lazy loading in web services because web services aren't going to be called on the fly when you access that property :d.
Say i have order
and orderDetails
table. In some scenarios I want orderDetails
as soon as I fetch order and in others I do not want orderdetails
.
I never faced this problem using stored procedures. But since Linq is standard for querying any data I am getting my hands on it.
So, how do I solve this problem?
Thanks in advance :)