Home

LINQPad 4 'System.Data.Linq.Table<table>' does not contain a definition for 'Include'...

I am trying to debug a LINQ query that uses an .Include directive, but when I put an Include in it I get the error:
'System.Data.Linq.Table<LINQPad.User.People>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Data.Linq.Table<LINQPad.User.People>' could be found (press F4 to add a using directive or assembly reference)

image

I tried hitting 'F4' and adding "System.Data.Objects" into the "Additional Namespace Imports" because I read somewhere it might help, but it did not make a difference.

I also saw a comment in another thread that Includes do not work with the default (LINQ to SQL) connection ( and why not, it should!). And I should use the "Entity Framework (DbContext)"
image
I tried to do that but have not been able to browse to a "Path to Custom Assembly" that LINQPad will accept. The prompt for the field is poor in the first as I am NOT using a Custom anything, but standard .net Framework.

I can not find any instructions that are detailed, or up to date, enough to allow me to debug a LINQ query that uses 'Include"s.
image

It was easy enough to set a "Default" connection, but evidently that does not support Includes.
image

Please tell me how I can edit and run LINQ queries that contain "Includes"

Comments

  • edited January 2018
    LINQ to SQL doesn't support the .Include method.

    The .Include method is part of Entity Framework, so it will work only if you connect to your own Entity Framework data context assembly that you've created in Visual Studio.

    If you haven't created a Entity Framework data context assembly in Visual Studio (or don't want to), there is workaround which is to select the members you're after:
    from c in Customers
    select new { c.Name, c.Orders, c.SalesPerson }
    You'll then see the expanded orders and salesperson in the results.



  • Thanks for the response Joe, but I mentioned in my problem description "Includes do not work with the default (LINQ to SQL) " and that I was NOT trying to use "LINQ to SQL" (for that reason) but EntityFramework. When using EntityFramework it gets very vague about which dll I should point to, and I have tried ALL the DLLs my solutions create but they all fail.
Sign In or Register to comment.