[英]c# Mvc Entity Framework issue with WHERE clause and Boolean values
有人可以幫我調整下面的語法嗎? 我不斷收到一條錯誤消息,指出“錯誤403'bool'不包含'ToList'的定義,並且找不到擴展方法'ToList'接受類型為'bool'的第一個參數(您是否缺少using指令或程序集參考?)”
var workerRecords =
from oe in context.tbl_Company_Workers.ToList()
where(
w => w.WorkerRoleID.HasValue && w.WorkerRoleID == 3
).ToList();
var workerRecords =
(from oe in context.tbl_Company_Workers
where w.WorkerRoleID.HasValue && w.WorkerRoleID == 3
select oe).ToList();
如果嚴格選擇3,為什么需要w.WorkerRoleID.HasValue?
var workerRecords =
(from oe in context.tbl_Company_Workers.ToList()
where oe.WorkerRoleID == 3 select oe
).ToList();
請使用語句進行檢查
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public void MethodName()
{
var workerRecords = context.tbl_Company_Workers.where(cw => w.WorkerRoleID.HasValue && w.WorkerRoleID.Value == 3).ToList();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.