开发者

Select rows in entity framework based on the presense of relations in other table

开发者 https://www.devze.com 2023-02-10 07:43 出处:网络
I\'m trying to execute following query with EF 4.0: IQueryable<FeedItem> result = from feedItem in database.FeedItems

I'm trying to execute following query with EF 4.0:

IQueryable<FeedItem> result =
            from feedItem in database.FeedItems
            where
                user.SubscriptionsToMessageGroup.Contains(feedItem.RelatedMessage.MessageGroup) &&
                feedItem.Id >= startFromId && feedItem.Id <= endAtId
            select feedItem;

Variable named 'user' contains EF entity and SubscriptionsToMessageGroup is a relation.

When running this query, I've g开发者_JAVA百科ot an error "Unable to create a constant value of type MessageGroup. Only primitive types are supported in this context."

Can you please explain the problem and tell me if there is any way to achieve what I'm trying to do?


Referencing Non-Scalar Variables Not Supported in LINQ to Entities. Look for more information here and a possible similar problem here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号