Referencing boolean field from LINQ results

I’m going cross-eyed with this, probably because it’s late in the day.
I’m executing custom code in a BPM and I am controlling the execution of the rest of the code from a field value returned from a query.

QuoteHed = (from QuoteHed_row in Db.QuoteHed
					where QuoteHed_row.Company == Session.CompanyID
					&& QuoteHed_row.QuoteNum == ttQuoteDtl_row.QuoteNum
					select QuoteHed_row).FirstOrDefault();

	bool contra = Convert.ToBoolean(QuoteHed.CheckBox02.ToString());
	if(contra)
	{
//execute if true
}

My code within the if statement executes regardless of the value of the variable. Am I referenceing the boolean value of QuoteHed.CheckBox02 correctly?

Wouldn’t converting the value of check box.ToString() always return true
because it would turn the control name, not value? Just a guess. Isn’t
there some sort of value property?

could be. Although, when I reference other values, like to place them in callContextBPM variables, the same method and syntax return the field values, not the control name.
Interestingly, it also executes if I take the reverse value

if(!contra)
{
//execute
}

Why are you converting to boolean. Checkbox is already a boolean

1 Like

So
if(QuoteHed.CheckBox02)
{
//execute
}
would be ok?

Yes sir

1 Like