Include() cause "Specified method is not supported" RRS feed

  • Question

  • I have been working on a query that is supposed to get all customers where the customers accounts sms/mms reported boolean is set to false. I have been able to get it working with one table (which contains the reported boolean) but when including the other tables it stops working and complaining that the method is not supported. I have tried to only include "smsin" and "smsout" and it crashes there already.

    Each customer have n accounts and each account have n smsins/smsouts/mmsins/mmsouts/positionings and those smsins etc have a boolean called reported that if set to false it should get the customer.

    Not working:

    var customers = db.Customers.Include(c => c.Accounts)
                            .Include(c => c.Subscription)
                            .Include(c => c.PricingLists)
                            .Include(c => c.Accounts.Select(a => a.SmsIns))
                            .Include(c => c.Accounts.Select(a => a.SmsOuts))
                            .Include(c => c.Accounts.Select(a => a.MmsIns))
                            .Include(c => c.Accounts.Select(a => a.MmsOuts))
                            .Include(c => c.Accounts.Select(a => a.Positionings))
                            .Where(c => c.Accounts.SelectMany(a => a.SmsIns.Select(s => s.Reported)).Contains(false) ||
                                   c.Accounts.SelectMany(a => a.SmsOuts.Select(s => s.Reported)).Contains(false) ||
                                   c.Accounts.SelectMany(a => a.MmsIns.Select(s => s.Reported)).Contains(false) ||
                                   c.Accounts.SelectMany(a => a.MmsOuts.Select(s => s.Reported)).Contains(false) ||
                                   c.Accounts.SelectMany(a => a.Positionings.Select(s => s.Reported)).Contains(false))

    Working: I have tested to only get the smsouts and it did work too

    var customers = db.Customers.Include(c => c.Accounts)
                            .Include(c => c.Subscription)
                            .Include(c => c.PricingLists)
                            .Include(c => c.Accounts.Select(a => a.SmsIns))
                            .Where(c => c.Accounts.SelectMany(a => a.SmsIns.Select(s => s.Reported)).Contains(false))

    Any ideas on how to solve this problem?
    Monday, August 13, 2012 1:02 PM

All replies

  • Hi,

    What exception are you getting when this crashes?

    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Tuesday, August 14, 2012 6:38 PM