0
如果我輸入一個字符串作爲參數,但是我想爲其提供一個字符串列表,而不是爲其提供一個項目的名稱,例如, 「AccountTracker」,我可以提供多個項目名稱,即「AccountTracker」,「GameX」,「HR1」。我怎樣才能轉換我的LINQ查詢來做到這一點?LINQ IQueryable with List <string>輸入參數
有以下關係員工(1-- )EmployeeProjects( l-1)項目
[WebGet]
public IQueryable<Employee> GetEmployeesByProjects(string project)
{
var employees = from ep in CurrentDataSource.EmployeeProjects
.Include("Project")
.Include("Employee")
where ep.Project.ProjectName == project
select ep.Employee;
return employees;
}
認爲您的語法看起來不錯,但在運行時,出現以下情況:服務器遇到處理請求的錯誤。異常消息是'Method'System.Linq.IQueryable'1 [Model.Employee] GetEmployeesByProjects1(System.Collections.Generic.List'1 [System.String])'有一個參數'System.Collections.Generic.List'1 [System.String]項目類型'System.Collections.Generic.List'1 [System.String]',不支持服務操作。只有原始類型被支持作爲參數。'。查看服務器日誌獲取更多詳細信異常堆棧跟蹤是: – user118190
嘗試我的第二個方法 – Damith
使用數據合同的項目列表,並將其作爲參數 – Damith