protected override Expression VisitConstant(ConstantExpression c) { var entityInfo = _infoProvider.FindEntityInfo(c.Type); if (entityInfo != null) { var dbTable = _dbFactory.BuildTable(entityInfo); var dbRef = _dbFactory.BuildRef(dbTable); var dbSelect = _dbFactory.BuildSelect(dbRef); dbRef.Alias = _nameGenerator.GenerateAlias(dbSelect, dbTable.TableName); _state.ResultStack.Push(dbSelect); } else if (!c.Type.IsAnonymouse()) { var dbConstant = _dbFactory.BuildConstant(c.Value, true); _state.ResultStack.Push(dbConstant); } return(c); }