I try to use where
clause in my LINQ queries. When I use numerical value, it's fine but when I want to compare string
value, it gives an error in where
clause.
string StartBarcode = (from s in datamodel.Packages
where s.RealBarcode == SelectedBarcode
select s.StartBarcode).FirstOrDefault().ToString();
IQueryable<PageData> q = (from v in datamodel.VW_WaypointDetails
where (v.RealBarcode == null) ? StartBarcode : v.RealBarcode
select new PageData
{
Name = v.Name,
Surname = v.Surname,
Description = v.Description
}
Errors are that 'Cannot convert lambda expression to type 'string' because it is not a delegate type' (I added System.Linq
) and Cannot implicitly convert type 'string' to 'bool'.
How can I use that switch-case
statement with string
value?
Thanks for all answers.