我是IQueryable,lambda表达式和LINQ的新手.我想在子句中放一个子查询,如下所示:
示例代码:
SELECT * FROM CLIENT c WHERE c.ETAT IN ( SELECT DDV_COLUMN_VAL FROM DATA_DICT_VAL WHERE TBI_TABLE_NAME = 'CLIENT' AND DD_COLUMN_NAME = 'STATUS' AND DDV_COLUMN_VAL_LANG_DSC_1 LIKE ('ac%'))
我如何在LINQ中翻译它?
解决方法
var innerquery = from x in context.DataDictVal where x.TbiTableName == myTableNameVariable && x.DdColumnName == "Status" && x.DdbColumnValLangDsc1.StartsWith("ac") select x.DdvColumnVal; var query = from c in context.Client where innerquery.Contains(c.Etat) select c;