开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜