开发者

Linq convert a Method Syntax to Query Expression

Recently I wrote this query with Linq (Method Syntax),开发者_如何转开发 notes: g.CmsContents is a Navigatiola Property.

I would like to know how to rewrite this code as a Linq Query Expression if it is possible.

var myGroupsTypesList = from g in context.CmsGroupsTypes
                        where g.CmsContents.Any(x => x.ContentId == myContentId)
                        select g;

Any idea? Thanks for your support :-)


That's already a query expression. If you mean you want to convert the Any part to another query expression - you can't. There's no query expression support for Any.

If you actually meant it the other way round, your query is equivalent to:

var myGroupsTypesList = context.CmsGroupsTypes
          .Where(g => g.CmsContents.Any(x => x.ContentId == myContentId));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜