-
Notifications
You must be signed in to change notification settings - Fork 0
LazyLoading
Marcin Sulecki edited this page Mar 28, 2017
·
2 revisions
Należy włączyć w konfiguracji Lazy Loading i tworzenie proxy
public MusicStoreContext()
: base("MusicStoreConnection")
{
this.Configuration.LazyLoadingEnabled = true;
this.Configuration.ProxyCreationEnabled = true;
}
Navigation Property musi być zdefiniowane jako publiczne i wirtualne
public class Artist : Base
{
public int ArtistId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual ICollection<Album> Albums { get; set; }
}
public MusicStoreContext()
: base("MusicStoreConnection")
{
this.Configuration.LazyLoadingEnabled = false;
}
Porada: wyłącz Lazy Loading gdy używasz serializacji na przykład podczas pracy z Web Services.