In the simplified code below,
if(city == \"New York City\")
{
var MyObject = from x in MyEFTable
where x.CostOfLiving == \"VERY HIGH\
you'll have to define the MyObject as a var before the condition:
var MyObject = from x in MyEFTable
where x.CostOfLiving == "SOMETHING THAT'LL RETURN NO ROWS"
select x.*;
This will assign a schema to the MyObject variable.
Now you can proceed with your condition as:
if(city == "New York City")
{
MyObject = from x in MyEFTable
where x.CostOfLiving == "VERY HIGH"
select x.*;
}
else
{
MyObject = from x in MyEFTable
where x.CostOfLiving == "MODERATE"
select x.*;
}