Part 8 Lazy loading in LINQ to SQL

Sdílet
Vložit
  • čas přidán 9. 09. 2014
  • Text version of the video
    csharp-video-tutorials.blogspo...
    Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our CZcams channel. Hope you can help.
    / @aarvikitchen5572
    Slides
    csharp-video-tutorials.blogspo...
    LINQ to SQL Tutorial - All Text Articles & Slides
    csharp-video-tutorials.blogspo...
    LINQ to SQL Tutorial Playlist
    • LINQ to SQL Tutorial
    Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
    czcams.com/users/kudvenka...
    In this video we will discuss the concept of Lazy loading in LINQ to SQL with an example.
    In this example there is a One-to-Many relationship between Department and Employee entities. A Department can have 1 or more employees. When Departments are loaded the related entities (Employee entities) are not loaded. Employee entities are only loaded when we iterate thru the employee objects belonging to a given department.
    To prove this, uncomment the following line and run the console application again. Notice that there is one query to retrieve all the departments and 3 queries to retrieve the employees belonging to each department.
    //dbContext.Log = Console.Out;
    So, what is Lazy Loading
    Lazy Loading means the related entities are not loaded until we iterate thru them or data bind them. By default, LINQ to SQL loads related entities by using Lazy Loading.
    In our next video, we will discuss how to change this behavior and eager load the related entities.

Komentáře • 11

  • @TheFlashinPulsar
    @TheFlashinPulsar Před 10 lety

    C++ programmer for 2 years here. I really like the way you have your C# videos split up. It makes coming to C# from another language easy by skipping through the video. Your audio quality has been getting better but I would like to give you a pro tip on getting high quality audio on the cheap. Get a Yeti snowball desktop mic. They are pretty cheap and I would put their audio quality just below Shure. Audio is a huge deal for making quality videos on CZcams; I just thought I would give you a heads up.

    • @MeAndSomeRandoms
      @MeAndSomeRandoms Před 9 lety

      I was a little confused because I know a microphone called BLUE YETI, and I think the microphone you mean is the BLUE SNOWBALL, Snowball costs around 50-60 bucks and has good sound for its price, Yeti costs around 100-110 bucks and has even better sound, I mean for non music voice recording the sound quality of the Yeti should be enough for anyone and also the price is pretty good for the quality. Both god microphones but I think I would just go for the Yeti because it is affordable and better so you do not come to the situation you have a good microphone for 60 but 1 year later you want to buy a better microphone pay 100 bucks, have 2 microphones, always just us the better one and in the end have paid 160 bucks for something you could have had for 100 in the first year.

  • @AmaZingVids
    @AmaZingVids Před 10 lety

    Your the best (y)

  • @nishucst
    @nishucst Před 6 lety +1

    Super Explanation

  • @ripperx444
    @ripperx444 Před 3 lety

    in python I can executeMany(list of prepared statements) but in EF 3.7 it takes a long ass time to select * and load it into memory and then if Find returns a record I need tk update otherwise add and then saveCahnges at end. Any idea how to speed this up?

  • @sinraj0007
    @sinraj0007 Před 10 lety

    thanx

  • @ashokp5805
    @ashokp5805 Před 8 lety +2

    what u told about Lazy Loading Concept...i cannt uderstand

    • @ammadkhan2352
      @ammadkhan2352 Před 4 lety +1

      he simply meant that the related entities are not loaded until we iterate through them.
      For example the object doesn't initialize unless you are not using it or going through it

  • @yoshimitsu411
    @yoshimitsu411 Před 8 lety

    Where do you get SampleDataContext from?