If you're not using the Entity Framework DbCollectionEntry object when working with an entity class's related objects, then your application is running too slow. Using DbCollectionEntry lets you asynchronously retrieve related objects and get only the objects you want.
Entity Framework Core doesn't have lazy loading (at least, not yet). But you can fake it by using explicit loading, though it doesn't work quite the way you might want. In fact, it's probably a good idea to use this in Entity Framework 6.
If you want to ensure that the right code is loaded at the right time (and only loaded when you need it), you can use TypeScript code to organize your code into modules. As a side benefit, managing your script tags will get considerably easier.
Some questions can only be answered by organizing your data into groups and then finding groups that contain particular members or have particular properties.
Complex queries can be solved with a combination of simpler LINQ queries, anonymous objects and the Group/By/Into clauses. Using Group/By/Into will also give you the best possible performance for those complex queries.
Here's a trick to have Marten automatically deserialize JSON data only when you want it to.
- By Jason Roberts
When you want to find all the objects that are missing a corresponding object, then you need the LINQ equivalent of an outer join. Here, step by painful step, is how to build that query.
If you decide on using an Enum with enumerated values in your Entity Framework class, here are the tools you'll need to make it work. But an enumerated value shouldn't be your first choice.
Here are two ways to save some typing when defining anonymous objects. One only works in Visual Basic, though.
Find the patterns in your data sets using these Clustering.R script tricks.
- By James McCaffrey
Marten is PostgreSQL-based, so take advantage of relational features where it makes sense. Here's an example.
- By Jason Roberts
Peter starts off with a perfectly good solution to a problem but then complicates the problem . . . and ends up moving to a different design pattern. While on that journey he has some best practices around designing Data Transfer Objects.
You probably use ToList to convert your LINQ results into Lists. It's almost as easy to convert any collection into a Dictionary whose items you can retrieve by key.
Sometimes life is like playing Whack-a-Mole: You write some code that solves a problem, and then someone comes along and makes the problem harder. Here's how to continuously integrate new solutions without having to rewrite your old solutions (much).
Whether you're building an application database or generating data access code, we've got a round-up of tools to make the job easier.
- By Terrence Dorsey