0

I want to start a Linq query with Visual Basic.

The query includes Eager Loading with Filtered Includes.

Customers should be invited who have at least one order.

Furthermore, I would like to limit the number of fields with Select.

So far I have tried the following:

Dim _List = Await (From _View In ctx.Customers.Where(Function(x) x.Customers_id.Equals(1000)) _
                  .Include(Function(z) z.Orders.Where(Function(i) i.Order_Price > 1000) _
                  .Select(Function(t) t.Order_Price)).ToListAsync

With the Select clause I want to display both Customersfields and Orderfields.

Unfortunately I get an error message, the command is not correct.

What am I doing wrong?

Dirk

7
  • What is the error that you get? Commented Apr 27 at 11:51
  • Start from removing Select. Commented Apr 27 at 12:13
  • Yes, you are right. If I don't use the Select clause, I don't get an error message. The problem then is that the data is not displayed to me in the form. I would also like to limit the fields because of performance.
    – OlafMS
    Commented Apr 27 at 13:00
  • When you use Select, includes are ignored. Post your desired DTO class. I'm not sure that I can write right LINQ in VB, but in C# definetly. Commented Apr 27 at 15:56
  • My customer table contains 40 fields, if I need to load them all, isn't it better to use join with a select clause?
    – OlafMS
    Commented Apr 28 at 18:36

0

Browse other questions tagged or ask your own question.