日期:2014-05-20  浏览次数:20667 次

这句sql这么转成LINQ 语句?
select * from m_code_type t where t.[type_code] like '%%'and t.[type_name] like '%%'
and exists (
select distinct type_code from m_code c where c.code_name like '%%' and c.type_code=t.type_code
)

------解决方案--------------------
C# code

//毛主席说,没有结帖习惯的程序员不是好厨师
var query=from t in m_code_type
          let temp=m_code.Where(c=>c.code_name.Contains("") && c.type_code ==t.type_code)
                         .Select(c=>c.type_code).Distinct()
          where t.type_code.Contains("") && t.type_name.Contains("")
          && temp.Any()
          select t;