简体   繁体   English

如何在sql查询中将此内容写入linq

[英]how to write this in sql query to linq

This is my sql query . 这是我的sql query

 select category from category where id in(select cid from subcategory)

I want to write this in linq . 我想用linq编写。 how can I write this . 我怎么写这个。

there is sample which i know , but this I'm unable to write this for my requirement 有我知道的示例,但是我无法根据我的要求编写此示例

from n in objvar
               where new[] { "Amit", "Kumar", "XYZ" }.Contains(n.hello)
               select n

A working solution would be 一个可行的解决方案是

 var res= from c in Category
                    join
                        s in SubCategory on c.id equals s.cid
                    select c;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM