I have a simple "Orders" table in which there are several entries. I am using code
Order order;
if (reg.OrderId != null)
{
order = db.Orders.Find(reg.OrderId);
}
else
{
order = new Order();
}
to get an existing order from my table. reg.OrderId computes a prime integer (e.g. 55).
When I go through the code, I get the error message: "This expression causes side effects and will not be evaluated"
But if I make the same call in LinqPad in the same context, it will return the data as expected. This seems like a very simple piece of code.
Why am I getting an error? And / or how to fix this problem further, since it works in LinqPad?
source
share