I'm trying to use Include extension on IQueryable set, but I have the following issue:
Error 1 'System.Linq.IQueryable<.Model.InsuranceCaseType>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable<.Model.InsuranceCaseType>' could be found (are you missing a using directive or an assembly reference?)
My code:
var allCaseTypes = Uow.InsuranceCaseType.GetAll().Include(a=>a.Geos);
Method GetAll()
returns - IQueryable<.Model.InsuranceCaseType>
I have in scope the following namespaces:
using System.Collections; using System.Collections.Generic; using System; using System.Data; using System.Linq; using System.Data.Entity; using System.IO; using System.Web; using System.Web.Mvc;
Include(IQueryable, String)Specifies the related objects to include in the query results.
The IQueryable interface inherits the IEnumerable interface so that if it represents a query, the results of that query can be enumerated. Enumeration causes the expression tree associated with an IQueryable object to be executed.
Both IEnumerable and IQueryable are forward collection. Querying data from a database, IEnumerable execute a select query on the server side, load data in-memory on a client-side and then filter data.
IQueryable is executed. // // Returns: // A System.Type that represents the type of the element(s) that are returned when. // the expression tree associated with this object is executed.
Include
is not an extension method on Queryable
, so it doesn't come together with all the usual LINQ methods. If you are using Entity Framework, you need to import the corresponding namespace:
using System.Data.Entity;
If you are using .Net core version then you need to install: Microsoft.EntityFrameworkCore nuget package.
And then:
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