Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️ Using Include() is super… | 20 comments (2024)

Dave Callan

Microsoft MVP | Senior Software Engineer | .NET Content Creator

  • Report this post

Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super common to eager load our child navigation collections, it's default usage however could potentially result in a lot of unnecessary data coming back, particularly in systems which deal with large volumes of data. Thankfully Entity Framework allows us to filter (and sort) our Includes() as the simple example below shows ...Do you use filtered Includes() much?

  • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (2)

336

20 Comments

Like Comment

Dave Callan

Microsoft MVP | Senior Software Engineer | .NET Content Creator

5d

  • Report this comment

Reposts appreciated to help support my content 😊

Like Reply

1Reaction

Sebastian Pinski

Software Development Manager - Financial Systems at Amazon Prime Video

5d

  • Report this comment

Not sure what the “Where” is doing in this example.

Like Reply

2Reactions 3Reactions

Allen Huber

16-year .NET developer (Blazor, UWP, MAUI, Windows Forms) on the verge of giving up | **Improving at** Web API, MVC, and WinApp SDK/WinUI3 | devblog.allenhuber.com/blog

5d

  • Report this comment

I don't use Entity Framework professionally but dabble on the side just to maintain a little hands-on. Based on my notes, I had never used this before, so I've learned something new! 👍

Like Reply

1Reaction 2Reactions

Kirill T.

Senior Software Engineer | .NET Core & Java Expert | Microservices & Scalable Systems | Driving Innovation in Tampa Bay’s Tech Industry

5d

  • Report this comment

Depends on project. Sometimes lazy loading is more comfortable. But not good idea for performance improvement. EF is useful tool but it requires some experience. Lately I’ve been using Dapper and gRPC instead of REST more often. One more time it always depends.

Like Reply

2Reactions 3Reactions

Manoj Jadhav

Senior Software Developer @ Weatherford | C# .Net Angular WCF WPF | SQL |EF| High Level and Low Level Design | System Design Principal | Database Design Principal | Agile Development | Micro-service architecture

5d

Dave Callan thanks for the sharing.how was the permanence in numbers if you can include will be helpful?

Like Reply

1Reaction 2Reactions

Kais Alar

Software Engineer | Backend Developer | .NET Core | C#

20h

  • Report this comment

Thanks a lot for sharing, but what about nested includes?

Like Reply

1Reaction

Poorna Soysa

Tech Enthusiast | .Net | C# | Azure | AWS

5d

  • Report this comment

I use. Nice feature. Thanks for sharing Dave

Like Reply

1Reaction 2Reactions

Nuno Figueira

Senior Software Engineer | Linux | Firmware Developer | Team player

4d

  • Report this comment

The first time I use include property was in EF7, just because this version apparently does not include by default some related entities... In my case on methods First, Find, Select...For exempla,BankAcount{Address,Contacts}Adress {}Contacts {}

Like Reply

1Reaction 2Reactions

Miguel Parra

Fullstack | .Net | SQL Server | Angular | HTML | CSS | Javascript | Microsserviços | RabbitMQ | Azure | DevOps | Redis | Ágil | SQL | API | REST | GIT | Entity Framework | C# | Docker | Espanhol | Inglês | Freelance

2d

  • Report this comment

Thanks for sharing

Like Reply

1Reaction

Savino Carlone

Solution Architect presso FATTUTTO | Torino .NET Meetup DotNetFoundation Organizer | Public Speaker | Press Office @Henoel Grech

5d

  • Report this comment

It is great. I use it.

Like Reply

1Reaction 2Reactions

See more comments

To view or add a comment, sign in

More Relevant Posts

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    𝗘𝘅𝗽𝗹𝗼𝗿𝗶𝗻𝗴 𝗖# 𝟭𝟮 𝗳𝗲𝗮𝘁𝘂𝗿𝗲𝘀 blog series 💡 Really enjoyed this four part series from David Pine on the main MS devblogs site which looks at how we might apply some of the new features of C# 12 such as primary constructors and collection expressions to our codebases. 𝗥𝗲𝗳𝗮𝗰𝘁𝗼𝗿 𝘆𝗼𝘂𝗿 𝗖# 𝗰𝗼𝗱𝗲 𝘄𝗶𝘁𝗵 𝗽𝗿𝗶𝗺𝗮𝗿𝘆 𝗰𝗼𝗻𝘀𝘁𝗿𝘂𝗰𝘁𝗼𝗿𝘀https://lnkd.in/eAqBaDeR𝗥𝗲𝗳𝗮𝗰𝘁𝗼𝗿 𝘆𝗼𝘂𝗿 𝗖# 𝗰𝗼𝗱𝗲 𝘄𝗶𝘁𝗵 𝗰𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻 𝗲𝘅𝗽𝗿𝗲𝘀𝘀𝗶𝗼𝗻𝘀https://lnkd.in/eNGf82Ft𝗥𝗲𝗳𝗮𝗰𝘁𝗼𝗿 𝘆𝗼𝘂𝗿 𝗖# 𝗰𝗼𝗱𝗲 𝗯𝘆 𝗮𝗹𝗶𝗮𝘀𝗶𝗻𝗴 𝗮𝗻𝘆 𝘁𝘆𝗽𝗲https://lnkd.in/eat-ReJp𝗥𝗲𝗳𝗮𝗰𝘁𝗼𝗿 𝘆𝗼𝘂𝗿 𝗰𝗼𝗱𝗲 𝘄𝗶𝘁𝗵 𝗱𝗲𝗳𝗮𝘂𝗹𝘁 𝗹𝗮𝗺𝗯𝗱𝗮 𝗽𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿𝘀https://lnkd.in/eqCiUCndWell worth a read 👍🏻

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (17)

    90

    8 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    .NET 8 new static code analyzers 💡I'm a big fan of using tooling where possible to help us improve our code and these new analyzers added in .NET 8 should help. Note ... CA1864 is not shown below but was also added in .NET 8 and catches occurrences of a Dictionary.Add call guarded by Dictionary.ContainsKey.Which ones will you turn on?

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (22)

    113

    7 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    𝗥𝗲𝗮𝗱𝗢𝗻𝗹𝘆𝗦𝗲𝘁<𝗧> coming in .NET 9 💡We already have ReadOnlyCollection<T> and ReadOnlyDictionary<TKey, TValue> but no ReadOnlySet<T>. A PR has been merged for this and I'd expect it to be released with .NET 9 Preview 6 in the 2nd or 3rd week of July.

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (27)

    109

    16 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    Welcome to .NET Aspire YouTube playlist ⬇️Intro to Aspire playlist, great if you haven't looked into Aspire much yet. Playlist Link -> https://lnkd.in/eN7TFhJb

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (32)

    149

    9 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    𝗚𝗲𝗻𝗲𝗿𝗶𝗰 𝗢𝗿𝗱𝗲𝗿𝗲𝗱𝗗𝗶𝗰𝘁𝗶𝗼𝗻𝗮𝗿𝘆 coming in .NET 9 🔥.NET does not currently have a genericOrderedDictionaryclass which has meant many of us have rolled own our solutions. Thankfully a PR adding a generic OrderedDictionary was merged two days ago and should be released with preview 6. This is awesome and should allow many of us to remove custom code and get the best performance from the built in implementation.

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (37)

    361

    25 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    Recommended Entity Framework YouTube playlist 💡Milan Jovanović has covered a lot of Entity Framework content on his YouTube channel over the last year, so much quality content here. Check it out -> https://lnkd.in/eHfMhEfk

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (42)

    168

    12 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    .NET 9 optimized static web asset delivery with new middleware 💡In .NET 9 (Preview 5+) 𝗠𝗮𝗽𝗦𝘁𝗮𝘁𝗶𝗰𝗔𝘀𝘀𝗲𝘁𝘀 is a new middleware that helps optimize the delivery of static assets in an app. It works with all UI frameworks, including Blazor, Razor Pages, and MVC. MapStaticAssetsoperates by combining build and publish-time processes to collect information about all the static resources in an app. This information is then utilized by the runtime library to efficiently serve these files to the browser by utilizing techniques such as 𝗯𝘂𝗶𝗹𝗱 𝘁𝗶𝗺𝗲 𝗴𝘇𝗶𝗽 𝗮𝗻𝗱 𝗯𝗿𝗼𝘁𝗹𝗶 𝗰𝗼𝗺𝗽𝗿𝗲𝘀𝘀𝗶𝗼𝗻.The image below (from MS) shows the original and compressed sizes of the CSS and JS files in the default Razor Pages template.What do you think?

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (47)

    167

    15 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    .𝗡𝗘𝗧 𝟵 𝗧𝗮𝘀𝗸.𝗪𝗵𝗲𝗻𝗘𝗮𝗰𝗵 𝗲𝘅𝗮𝗺𝗽𝗹𝗲 💡.NET 9 Preview 5 is now available and contains lots of goodies for us including the ability to 𝗲𝗮𝘀𝗶𝗹𝘆 𝗽𝗿𝗼𝗰𝗲𝘀𝘀 𝗮𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝘁𝗮𝘀𝗸𝘀 𝗮𝘀 𝘁𝗵𝗲𝘆 𝗰𝗼𝗺𝗽𝗹𝗲𝘁𝗲. The simple example below makes multipleHttpClientcalls and is able to operate on their results as they complete. What do you think?

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (52)

    655

    42 Comments

    Like Comment

    To view or add a comment, sign in

  • Dave Callan

    Microsoft MVP | Senior Software Engineer | .NET Content Creator

    • Report this post

    Vertical Slice Architecture example 💡In this simple example everything (except .cshtml) is in one file, it's very developer friendly. No hopping between multiple projects, no repository pattern, no specification pattern, no MediatR, no indirection, no abstraction fetish that we typically see in our apps, no bloat ... just enough code to meet the requirements of the use case. Of course it's not going to work for all apps and use cases but try and at least consider if this approach will work for you.

    • Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (57)

    127

    43 Comments

    Like Comment

    To view or add a comment, sign in

Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (61)

Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️Using Include() is super… | 20 comments (62)

55,232 followers

  • 1,565 Posts
  • 23 Articles

View Profile

Follow

More from this author

  • eShopOnWeb Architecture (16/16) - uses clean architecture Dave Callan 2y
  • eShopOnWeb Architecture (15/16) – has a really nice example of the Interface Segregation Principle Dave Callan 2y
  • eShopOnWeb Architecture (14/16) – uses parameterized tests Dave Callan 2y

Explore topics

  • Sales
  • Marketing
  • Business Administration
  • HR Management
  • Content Management
  • Engineering
  • Soft Skills
  • See All
Dave Callan on LinkedIn: Entity Framework FILTERED INCLUDE() example ⬇️

Using Include() is super… | 20 comments (2024)

References

Top Articles
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 6017

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.