lazy-loading

When should one avoid using NHibernate's lazy-loading feature?

Most of what I hear about NHibernate's lazy-loading, is that it's better to use it, than not to use it. It seems like it just makes sense to minimize database access, in an effort to reduce bottlenecks. But few things come without trade-offs, certainly it slightly limits design by forcing you to have virtual properties. But I've also ...

Entity Framework and Object Context lifetime in ASP.NET MVC

Hi there I'm using Entity Framework in my project, and I have the problem that, once I pass my entities to a View (keep in mind that these entities have lazy-initialized objects along the lines of: Products.Owner, where owner is an object that is lazily initialized) I get a run-time exception telling me that the ObjectContext is out of ...

NHibernate - access the ID of an associated object without lazy loading the whole object

I have two associated business objects - A and B. the association is (A->B)many-to-one, with B.Id a foreign key in A (so A has A.B_id in the DB). I'm using lazy=true and solved most of my problems, however in A's ToString I want to print also A.B.Id, which I should have without further trips to the DB. but accessing A.B activates the pr...

NHibernate lazy loading part of a map

Hi all, I was wondering if there is any way to lazy load part of map in NH? Here is my mapping: <map name="Resources" table="COUNTRY_TL" fetch="subselect"> <cache region="CountryCache" usage="read-write" include="all"/> <key column="COUNTRY_ID"/> <index column="LANGUAGE_CODE" type="System.String"></index> <composite-element cl...

How do I implement lazy module loading in Perl?

How can I implement lazy module loading in Perl? I've seen similar things in python and implementation is somewhat simpler, but in Perl I think this would be a bit harder. ...

How do I implement toString() in a class that is mapped with Hibernate?

I have an instance of a class that I got from a Hibernate session. That session is long gone. Now, I'm calling toString() and I'm getting the expected LazyInitializationException: could not initialize proxy - no Session since I'm trying to access a reference which Hibernate didn't resolve during loading of the instance (lazy loading). I...

Is Shared ReadOnly lazyloaded?

Hello! I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? How about ReadOnly itself without the shared? Example: System.Type.Delimiter ...

Fetched Properties v Relationships (Core Data - iPhone)

I'm a new iPhone developer (of about 4 months or so) who is starting to look at Core Data. In the "Beginning iPhone 3 Development" book by Dave Mark it mentions that the main difference between fetched properties and relationships is that fetched properties allow lazy loading. However, I have seen other resources and accepted answers o...

Is EntityReference.Load checking for EntityReference.IsLoaded?

Hi I was wondering if EntityReference.Load method includes If Not ref.IsLoaded Then ref.Load() My question is basically: Dim person = Context.Persons.FirstOrDefault person.AddressReference.Load() person.AddressReference.Load() 'Does it do anything? ...

GridView doesn't cause NHibernate proxy to load relationships

I'm currently learning NHibernate and I would like to data-bind to Web controls (i.e. GridView). In my current example I am using Fluent NHibernate to map two tables to their business objects (Project and ProjectStatus). I also have a "Project has a ProjectStatus" (many-to-one) relationship. Structure of Project class: Project.ID Proj...

nHibernate Collection Count

I have the following model which I have created and mapped with nHibernate. Using lazy loading so I don't need to get the Vehicles for the Dealer at the start. Public class Dealer { public virtual string Name { get;set;} public virtual IList Vehicles { get;set;} } Now lets assume the Dealer has thousands of vehicles. If I do Dealer.Ve...

How do I compare an object with an NHibernate proxy object?

I'm using Compare .NET Objects to test whether my POCOs are persisted correctly to a test database. Let's take an example POCO: public class NoahsArk { public virtual Noah Noah { get; set; } } And the mapping file, using FNH: public class NoahsArkMap : ClassMap<NoahsArk> { References(x => x.Noah).Cascade.All(); } Now, I run...

JQuery plugin for lazy-loading/lazy-evaluation?

Is there such jQuery plugin? More specific: I want to use some elegant and easy way to postpone some code execution until it's really needed (some event happens). And when this event happens, the postponed code should get executed only once. Some kind of lazy initialization. For example, apply some animation to an element not when docu...

Lazy/Eager loading strategies in remoting cases (JPA)

I'm running into LazyLoading exceptions like the most people who try remoting with an ORM. In most cases switching to eager fetching solves the problem (Lazy Loading / Non atomic queries / Thread safety / n+1 problem ...). But eager fetching has also disadvantages if you are dealing with a really big object graph. Loading the whole ob...

Advanced topic of dynamic lazy loading of DLLs in silverlight application

It's a common sense when you are developing a big silverlight application that break it into many small components, to make the original XAP file relatively small and dynamically load the necessary DLLs from the server side on demand. An easy way is to download(From WebClient) the dll in the program in the runtime accroding to the URL s...

CGImage/UIImage lazily loading on UI thread causes stutter

My program displays a horizontal scrolling surface tiled with UIImageViews from left to right. Code runs on the UI thread to ensure that newly-visible UIImageViews have a freshly loaded UIImage assigned to them. The loading happens on a background thread. Everything works almost fine, except there is a stutter as each image becomes ...

the nhibernate cross machine lazy load problem

i got a client a server and a db db mapped to server with fluent nhibernate. so far so good the client talks with the server with wcf. i want to implement lazy loading on client side. is there any solution out there? ...

POCO objects with lazy loading

Hi! I'am new to ASP.NET MVC, IoC, POCO, etc. So I want to know is it OK to use such kind of architecture. This is my demo project. Project.Core (this assembly referenced by all project) public class User { public string Name {get; set;} public List<UserGroup> UserGroups{get; set} } public class UserGroup { public string Tit...

Rewrite this foreach yield to a linq yield?

Say I have the following code (context narrowed down as to keep the question scope limited) public static IEnumerable<Color> GetThemColors(){ var ids = GetThePrimaryIds(); foreach (int id in ids){ yield return GetColorById(id); } ids = GetTheOtherIds(); foreach (int id in ids){ yield return GetOtherColorsById(id); } } I woul...

NHibernate: Lazyload single property

Hi, I have currently moved my blogengine over from Linq2Sql to NHIbernate. I'm stuck at the following performance problem: I got one table: 'Posts', that has Id, Title, PostContent, DateCreated collumns and so on. The problem is that, when I'm creating the "Recent posts list", I don't want the whole PostContent. In Linq2Sql you can s...