I am using entity framework and I can't find include method like in this example:
using(ArticleExtractorEntities db=new ArticleExtractorEntities())
{
Preference pref= db.Preferences.Include(
here i find only the function include with the parameter (string path) and I don't find any other overload so how can I use Include with lambda expression?
The term 'Lambda expression' has derived its name from 'lambda' calculus which in turn is a mathematical notation applied for defining functions. Lambda expressions as a LINQ equation's executable part translate logic in a way at run time so it can pass on to the data source conveniently.
The Find method on DbSet uses the primary key value to attempt to find an entity tracked by the context. If the entity is not found in the context then a query will be sent to the database to find the entity there. Null is returned if the entity is not found in the context or in the database.
LINQ include helps out to include the related entities which loaded from the database. It allows retrieving the similar entities to be read from database in a same query. LINQ Include() which point towards similar entities must read from the database to get in a single query.
Lambda expressions and tuples The C# language provides built-in support for tuples. You can provide a tuple as an argument to a lambda expression, and your lambda expression can also return a tuple. In some cases, the C# compiler uses type inference to determine the types of tuple components.
it's not in System.Linq. Add
using System.Data.Entity
Update. For those looking how it extend your linq query with .Include()
No longer is it:
using System.Data.Entity;
With netcoreapp1.0 it is:
using Microsoft.EntityFrameworkCore;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With