I have the following LINQ To Entities query (in simplified form):
ctx.BattlesUsers.Where(bu => bu.DateTime == ctx.BattlesUsers.
Where(BattleUserSpecifications.BattleIdIsEqualTo(bu.BattleId)).
Max(bu1 => bu1.DateTime));
which throws exception "Internal .NET Framework Data Provider error 1025.".
The problem here is my specification call. The usual solution for this problem is to move specification expression call out of query and pass expression directly to Where. But it won't work here as I need to pass bu.BattleId to the expression.
Update.
Here is the code of BattleIdIsEqualTo:
public static Expression<Func<Model.Entities.BattleUser, bool>> UserIdIsEqualTo(long userId)
{
return bu => bu.UserId == userId;
}