So lets say I’m retrieving some data with a linq query as so:
DataContext db = new DataContext
using(db)
{
var test = from t in db.table1
where t.col1 == Convert.ToInt32(HiddenField1.Value)
select new
{
t.col2,
t.col3
};
}
I then want to check if a condition is not true like:
if (col3 != something){ }
How can I achieve this?
Thanks
If your check is supposed to be done in sql, then the answer by Dave Markle must suit you.
If you want to apply this check on some of the returned entities, it should look somewhat like this:
get your objects through
foreach:foreach(var o in test){
if(o.col3!= something)
{
...
}
}
or use linq to objects:
test.ToList().Where(o=>o.col3!=something);