Reputation: 1885
can someone please assist me adjust my syntax below. I keep getting an error that says "Error 403 'bool' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)"
var workerRecords =
from oe in context.tbl_Company_Workers.ToList()
where(
w => w.WorkerRoleID.HasValue && w.WorkerRoleID == 3
).ToList();
Upvotes: 0
Views: 862
Reputation: 1
Please chekc using statements
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();
}
}
Upvotes: 0
Reputation: 2132
why do you need w.WorkerRoleID.HasValue if you are strictly selecting 3?
var workerRecords =
(from oe in context.tbl_Company_Workers.ToList()
where oe.WorkerRoleID == 3 select oe
).ToList();
Upvotes: 0
Reputation: 7135
var workerRecords =
(from oe in context.tbl_Company_Workers
where w.WorkerRoleID.HasValue && w.WorkerRoleID == 3
select oe).ToList();
Upvotes: 1