Linq to SQL Where In Clause Causes The object is not installed in the instance of the object

I have two tables, subscriptions and topics. Each subscription is associated with a specific topic (PK for the topic table). The first request works fine and retrieves the topicID of all the videos that were uploaded today.

The problem occurs when I try to use query1 results as a where-in clause for query 2. I keep getting a reference to an object not installed in the object instance.

Request 1

IQueryable<int> topics = (from t in dataLayer.Videos
                  where SqlMethods.DateDiffDay(t.DateCreated, DateTime.Today) == 0
                 select t.TopicID).Distinct();

Request 2 (failure)

 IQueryable<Subscription> subs = from s in dataLayer.Subscriptions
                                     where topics.Contains(s.TopicID)
                                     select s;

Linq query generated on error, {Table(Subscription).Where(s => value(EmailSubscribers+<>c__DisplayClass0).topics.Contains(s.TopicID))}

Any understanding of this would be appreciated. I looked through several samples on the net, and they all seem to me similar.

+3
source share
1 answer

ToList() , .

+2

Source: https://habr.com/ru/post/1752561/


All Articles