Entity Framework Extensions Collection

In the lasts months I’ve been working on a project where I use Entity Framework. For this project I was developing some extension methods that facilitate working with EFX. My favorites are:

  • Include: allows to configure the eager load with expressions rather than strings.
  • EnsureLoad: allows to load a collection or reference safely with lazy load.
  • LoadByKey: If an object is in the context this method returns it. Otherwise return the object from the database.
  • ToTraceQuery: similiar to .ToTraceString( ) but better :).

Download the code of this extensions from here.

Leave a Reply