c# Mvc实体框架的WHERE子句和布尔值问题



谁能帮我调整一下下面的语法?我不断得到一个错误,说"错误403 'bool'不包含'ToList'的定义,没有扩展方法'ToList'接受类型'bool'的第一个参数可以找到(你是否缺少使用指令或汇编引用?)"

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.w erroleid . 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();
    }
 }