Say we have the entity Customer { FirstName, LastName, Age } and the following query:

var models = from c in session.Query.All<Customer>() select new CustomerViewModel(c.FirstName);

We are only interested in select and displaying the FirstName field. Why does DO load the LastName and Age properties? Is it under the impression that I would mark them as lazy if I don't want them loaded... even if my query is explicitly stating the fields to be loaded through the projection?

Is there a performance hit if I mark every field as lazy? Since I only want prefetched and projected fields to be loaded in any query?

asked Jan 13 '11 at 23:51

ara's gravatar image

ara
395858791


One Answer:

Ara,

As DataObjects.Net tries to minimize the number of round trips to database, it loads all fields that are not marked as "Lazy" at Entity materialization. This is much more "cheaper" from the performance point of view than fetching a single field for every Entity in separate queries.

Using "Lazy" fields does make sense when working with blobs or texts of huge size, especially keeping in mind the fact that physically they are located not inside the database row, but in a separate blob storage.

answered Jan 14 '11 at 00:15

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA