Changed some code around today (property to a method) and am now getting the error: The binary operator Equal is not defined for the types 'System.Nullable`1[System.Int32]' and 'System.Int32'. on a LINQ query.
The code (contrived):
public class Something
{
private LoginEntity _login;
public LoginEntity Login
{
get {
if (_login == null)
_login = new LoginEntity(1);
return _login;
}
}
public LoginEntity GetLogin()
{
return Login;
}
private IList<OrdersEntity> GetOrders()
{
//See below
}
}
Notes: the LoginEntity ClientId is nullable, the OrdersEntity ClientId is not (though if it is, the error still happens).
This Errors out (using method):
return new LinqMetadata().Orders.Where(o => o.ClientId == GetLogin().ClientId).ToList();
So does this (using field):
return new LinqMetadata().Orders.Where(o => o.ClientId == _login.ClientId).ToList();
This does not error (using property):
return new LinqMetadata().Orders.Where(o => o.ClientId == Login.ClientId).ToList();
If I make the property anything but public, it errors also.
This also does not error (using local variable):
int? clientId = _login.ClientId;
return new LinqMetadata().Orders.Where(o => o.ClientId == clientId).ToList();
Should these all work the same?
Brian
ORM Lib Version: 2.6.9.327
LINQ Lib Version: 2.6.9.331
SQL Server Lib Version: 2.6.8.1114