This looks like a bug in Lightspeed 3.0 build 13186. Can you let me know if it can be fixed in a nightly build?
In Lightspeed 2.2 the following query worked but in Lightspeed 3.0 we get the following exception.
var query = (from gameHistory in uow.HistoryEntities
where gameHistory.HistoryGame.ApplicationInstance.Id == appInstanceId
orderby gameHistory.Id descending
select gameHistory).FirstOrDefault();
Object reference not set to an instance of an object.
at Mindscape.LightSpeed.Linq.Sqo.Where.WalkAndExtractAssociation(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.Where.ProcessCriteriaForRequiredJoins(QueryExpression criteria, LinqQueryPlanExpression plan, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Sqo.Where.ProcessCriteriaForRequiredJoins(QueryExpression criteria, LinqQueryPlanExpression plan, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Sqo.Where.Evaluate(ExpressionVisitor visitor, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.VisitMethodCall(MethodCallExpression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Visit(Expression exp)
at Mindscape.LightSpeed.Linq.Sqo.OrderSqo.Evaluate(ExpressionVisitor visitor, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.VisitMethodCall(MethodCallExpression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Visit(Expression exp)
at Mindscape.LightSpeed.Linq.Sqo.First.Evaluate(ExpressionVisitor visitor, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.VisitMethodCall(MethodCallExpression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Visit(Expression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Build(Expression translation, LinqQueryProvider provider)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.GetExecutionPlan(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
at BlueYonder.Server.BusinessProcesses.ApplicationBP.FindLastApplicationTransactionId(Int64 appInstanceId)
If I change the query to the following then it works.
var query = (from gameHistory in uow.HistoryEntities
where (gameHistory.HistoryGame != null) &&
(gameHistory.HistoryGame.ApplicationInstance.Id == appInstanceId)
orderby gameHistory.Id descending
select gameHistory).FirstOrDefault();