c# - Forcing eager-loading for a navigation property -


i'm using ef code first , have navigation property called category want eager loaded in every call:

public class product {     ...     public category category { get; set; } } 

to have include in every call i'll on product

var results = p in db.products.include("category") select p; 

is there way have category property eager loaded, therefore generation sql join, in every call without having include every time?

thank you

you can use helper method proposed @jeroenh not solve situation example want load order ordered products , categories. ef doesn't have automatic eager loading configuration example available in linq-to-sql. must use include (either directly or helper construction).


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -