List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:March 3 2011 6:02pm
Subject:bzr commit into connector-net-trunk branch (reggie.burnett:967)
View as plain text  
#At file:///C:/Users/Reggie/work/connector-net/6.3/ based on revid:reggie.burnett@strippednqgx9jd70s

  967 Reggie Burnett	2011-03-03 [merge]
      merged

    added:
      MySql.Data.Entity/Tests/Properties/SQLSyntax.Designer.cs
      MySql.Data.Entity/Tests/Properties/SQLSyntax.resx
    modified:
      CHANGES
      MySql.Data.Entity/Provider/Fragments/InputFragment.cs
      MySql.Data.Entity/Provider/Fragments/SqlFragment.cs
      MySql.Data.Entity/Provider/Fragments/TableFragment.cs
      MySql.Data.Entity/Provider/Generators/SelectGenerator.cs
      MySql.Data.Entity/Provider/Generators/SqlGenerator.cs
      MySql.Data.Entity/Provider/Metadata.cs
      MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl
      MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl
      MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl
      MySql.Data.Entity/Provider/Statements/SelectStatement.cs
      MySql.Data.Entity/Tests/AggregateOperators.cs
      MySql.Data.Entity/Tests/BaseEdmTest.cs
      MySql.Data.Entity/Tests/CanonicalFunctions.cs
      MySql.Data.Entity/Tests/InsertTests.cs
      MySql.Data.Entity/Tests/JoinTests.cs
      MySql.Data.Entity/Tests/MySql.Data.Entity.Tests.csproj
      MySql.Data.Entity/Tests/OrderingAndGrouping.cs
      MySql.Data.Entity/Tests/Paging.cs
      MySql.Data.Entity/Tests/RelationalOperators.cs
      MySql.Data.Entity/Tests/RestrictionOperators.cs
      MySql.Data.Entity/Tests/SetOperators.cs
      MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs
      MySql.Data/Tests/Source/CommandTests.cs
      MySql.Data/Tests/Source/ConnectionStringBuilder.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2011-02-18 15:26:03 +0000
+++ b/CHANGES	2011-03-03 18:02:14 +0000
@@ -9,6 +9,7 @@
   (MySQL bug #59989, Oracle bug #11776346)
 - fixed NullReferenceException when a timeout occurred inside a TransactionScope
   (MySQL bug #59346, Oracle bug #11766272)
+- small but important improvements in EF sql generation
 
 Version 6.3.6
 - Fixed TracingDriver so that it normalizes long queries before truncation so we don't get exceptions     

=== modified file 'MySql.Data.Entity/Provider/Fragments/InputFragment.cs'
--- a/MySql.Data.Entity/Provider/Fragments/InputFragment.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Fragments/InputFragment.cs	2011-03-03 18:01:04 +0000
@@ -45,17 +45,12 @@
 
         public string Name { get; set; }
         public bool IsWrapped { get; private set; }
-
-        public virtual SqlFragment GetProperty(string propertyName)
-        {
-            if (Left != null && Left.Name == propertyName) return Left;
-            if (Right != null && Right.Name == propertyName) return Right;
-            return null;
-        }
+        public bool Scoped { get; set; }
 
         public virtual void Wrap(Scope scope)
         {
             IsWrapped = true;
+            Scoped = true;
 
             if (scope == null) return;
             if (Left != null)

=== modified file 'MySql.Data.Entity/Provider/Fragments/SqlFragment.cs'
--- a/MySql.Data.Entity/Provider/Fragments/SqlFragment.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Fragments/SqlFragment.cs	2011-03-03 18:01:04 +0000
@@ -30,9 +30,13 @@
 {
     internal abstract class SqlFragment
     {
+        static char[] quoteChars = new char[3] { '\'', '"', '`' };
+
         protected string QuoteIdentifier(string id)
         {
-            return String.Format("`{0}`", id);
+            if (id.IndexOfAny(quoteChars) >= 0)
+                return String.Format("`{0}`", id);
+            else return id;
         }
 
         public abstract void WriteSql(StringBuilder sql);
@@ -67,7 +71,7 @@
 
         public override void WriteSql(StringBuilder sql)
         {
-            if (IsNegated)
+            if (IsNegated && Operator != "=")
                 sql.Append("NOT (");
 
             // do left arg
@@ -77,7 +81,10 @@
             if (WrapLeft)
                 sql.Append(")");
 
-            sql.AppendFormat(" {0} ", Operator);
+            if (IsNegated && Operator == "=")
+                sql.Append(" != ");
+            else
+                sql.AppendFormat(" {0} ", Operator);
 
             // now right arg
             if (WrapRight)
@@ -85,7 +92,7 @@
             Right.WriteSql(sql);
             if (WrapRight)
                 sql.Append(")");
-            if (IsNegated)
+            if (IsNegated && Operator != "=")
                 sql.Append(")");
         }
     }
@@ -119,15 +126,14 @@
 
     internal class ColumnFragment : SqlFragment
     {
-        public ColumnFragment(string table, string name)
+        public ColumnFragment(string tableName, string columnName)
         {
-            TableAlias = TableName = table;
-            ColumnName = name;
+            TableName = tableName;
+            ColumnName = columnName;
         }
 
         public SqlFragment Literal { get; set; }
         public string TableName { get; set; }
-        public string TableAlias { get; set; }
         public string ColumnName { get; set; }
         public string ColumnAlias { get; set; }
 
@@ -138,12 +144,13 @@
                 Debug.Assert(ColumnAlias != null);
                 Literal.WriteSql(sql);
             }
-            else
+            else 
             {
-                if (TableAlias != null)
-                    sql.AppendFormat("{0}.", QuoteIdentifier(TableAlias));
+                if (TableName != null)
+                    sql.AppendFormat("{0}.", QuoteIdentifier(TableName));
                 sql.AppendFormat("{0}", QuoteIdentifier(ColumnName));
             }
+
             if (ColumnAlias != null && ColumnAlias != ColumnName)
                 sql.AppendFormat(" AS {0}", QuoteIdentifier(ColumnAlias));
         }
@@ -165,7 +172,6 @@
             Argument.WriteSql(sql);
             sql.Append(")");
         }
-
     }
 
     internal class FunctionFragment : SqlFragment
@@ -280,6 +286,11 @@
         {
             throw new NotImplementedException();
         }
+
+        public string LastProperty
+        {
+            get { return Properties.Count == 0 ? null : Properties[Properties.Count - 1]; }
+        }
     }
 
     internal class SortFragment : SqlFragment
@@ -290,14 +301,19 @@
             Ascending = ascending;
         }
 
-        public SqlFragment Column { get; set; }
+        public SqlFragment Column 
+        { 
+            get; 
+            set; 
+        }
         public bool Ascending { get; set; }
 
         public override void WriteSql(StringBuilder sql)
         {
-            Debug.Assert(Column is ColumnFragment);
-            ColumnFragment f = Column as ColumnFragment;
-            sql.AppendFormat("{0} {1}", QuoteIdentifier(f.ColumnName), Ascending ? "ASC" : "DESC");
+            ColumnFragment columnFragment = Column as ColumnFragment;
+            Debug.Assert(columnFragment != null);
+            columnFragment.WriteSql(sql);
+            sql.AppendFormat(" {0}", Ascending ? "ASC" : "DESC");
         }
     }
 

=== modified file 'MySql.Data.Entity/Provider/Fragments/TableFragment.cs'
--- a/MySql.Data.Entity/Provider/Fragments/TableFragment.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Fragments/TableFragment.cs	2011-03-03 18:01:04 +0000
@@ -36,12 +36,9 @@
         public TypeUsage Type;
         public List<ColumnFragment> Columns;
 
-        public override SqlFragment GetProperty(string propertyName)
+        public TableFragment()
         {
-            if (Columns == null) return null;
-            foreach (ColumnFragment col in Columns)
-                if (col.ColumnName == propertyName) return col;
-            return null;
+            Scoped = true;
         }
 
         public override void WriteSql(StringBuilder sql)

=== modified file 'MySql.Data.Entity/Provider/Generators/SelectGenerator.cs'
--- a/MySql.Data.Entity/Provider/Generators/SelectGenerator.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Generators/SelectGenerator.cs	2011-03-03 18:01:04 +0000
@@ -83,6 +83,8 @@
             // first process the input
             DbGroupExpressionBinding e = expression.Input;
             SelectStatement innerSelect = VisitInputExpressionEnsureSelect(e.Expression, e.VariableName, e.VariableType);
+            scope.Add(e.GroupVariableName, innerSelect);
+
             SelectStatement select = WrapIfNotCompatible(innerSelect, expression.ExpressionKind);
 
             CollectionType ct = (CollectionType)expression.ResultType.EdmType;
@@ -121,7 +123,9 @@
             FunctionFragment fragment = new FunctionFragment();
             fragment.Name = fa.Function.Name;
             if (fa.Function.Name == "BigCount")
-                fragment.Name = "Count";
+                fragment.Name = "COUNT";
+            else
+                fragment.Name = fa.Function.Name.ToUpperInvariant();
 
             fragment.Distinct = fa.Distinct;
             fragment.Argmument = arg;
@@ -164,15 +168,18 @@
             if (select.IsCompatible(expressionKind)) return select;
             SelectStatement newSelect = new SelectStatement();
             select.Wrap(scope);
+            select.Scoped = true;
             newSelect.From = select;
             return newSelect;
         }
 
         private void WrapJoinInputIfNecessary(InputFragment fragment, bool isRightPart)
         {
-            if (fragment is SelectStatement ||
-                fragment is UnionFragment)
+            if (fragment is SelectStatement || fragment is UnionFragment)
+            {
                 fragment.Wrap(scope);
+                fragment.Scoped = true;
+            }
             else if (fragment is JoinFragment && isRightPart)
                 fragment.Wrap(null);
         }
@@ -246,10 +253,11 @@
 
         public override SqlFragment Visit(DbLimitExpression expression)
         {
-            SelectStatement statement = (SelectStatement)VisitInputExpressionEnsureSelect(
+            SelectStatement select = (SelectStatement)VisitInputExpressionEnsureSelect(
                 expression.Argument, null, null);
-            statement.Limit = expression.Limit.Accept(this);
-            return statement;
+            select = WrapIfNotCompatible(select, expression.ExpressionKind);
+            select.Limit = expression.Limit.Accept(this);
+            return select;
         }
 
         public override SqlFragment Visit(DbSkipExpression expression)
@@ -257,13 +265,15 @@
             SelectStatement select = VisitInputExpressionEnsureSelect(expression.Input.Expression, expression.Input.VariableName,
                 expression.Input.VariableType);
 
+            select = WrapIfNotCompatible(select, DbExpressionKind.Sort);
             foreach (DbSortClause sortClause in expression.SortOrder)
             {
                 select.AddOrderBy(
                     new SortFragment(sortClause.Expression.Accept(this), sortClause.Ascending));
             }
 
-
+            // if we wrapped above, then this wrap will not create a new one so there
+            // is no harm in calling it
             select = WrapIfNotCompatible(select, expression.ExpressionKind);
             select.Skip = expression.Count.Accept(this);
             return select;
@@ -277,11 +287,11 @@
 
             SelectStatement left = VisitInputExpressionEnsureSelect(expression.Left, null, null);
             Debug.Assert(left.Name == null);
-            left.Wrap(null);
+//            left.Wrap(null);
 
             SelectStatement right = VisitInputExpressionEnsureSelect(expression.Right, null, null);
             Debug.Assert(right.Name == null);
-            right.Wrap(null);
+  //          right.Wrap(null);
 
             f.Left = left;
             f.Right = right;

=== modified file 'MySql.Data.Entity/Provider/Generators/SqlGenerator.cs'
--- a/MySql.Data.Entity/Provider/Generators/SqlGenerator.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Generators/SqlGenerator.cs	2011-03-03 18:01:04 +0000
@@ -81,21 +81,34 @@
             // if we are not at the top level property then just return
             if (propertyLevel > 0) return fragment;
 
-            // we are at the top level property so now we can do our work
-            ColumnFragment column = GetColumnFromPropertyTree(fragment);
+            ColumnFragment column = new ColumnFragment(null, fragment.LastProperty);
+            column.TableName = FindInputFromProperties(fragment);
 
-            for (int i = fragment.Properties.Count - 1; i >= 0; --i)
-            {
-                InputFragment inputFragment = scope.GetFragment(fragment.Properties[i]);
-                if (inputFragment != null)
-                {
-                    column.TableAlias = inputFragment.Name;
-                    break;
-                }
-            }
             return column;
         }
 
+        private string FindInputFromProperties(PropertyFragment fragment)
+        {
+            Debug.Assert(fragment != null);
+            PropertyFragment propertyFragment = fragment as PropertyFragment;
+            Debug.Assert(propertyFragment != null);
+
+            if (propertyFragment.Properties.Count >= 2)
+            {
+                for (int x = propertyFragment.Properties.Count - 2; x >= 0; x--)
+                {
+                    string reference = propertyFragment.Properties[x];
+                    InputFragment input = scope.GetFragment(reference);
+                    if (input == null) continue;
+                    if (input.Scoped) return input.Name;
+                    if (input is SelectStatement)
+                        return (input as SelectStatement).From.Name;
+                    continue;
+                }
+            }
+            return null;
+        }
+
         public override SqlFragment Visit(DbScanExpression expression)
         {
             EntitySetBase target = expression.Target;
@@ -154,8 +167,7 @@
             if (literal != null)
                 return new LiteralFragment(literal);
             else if (pt == PrimitiveTypeKind.Boolean)
-                return new LiteralFragment(String.Format("cast({0} as decimal(0,0))",
-                    (bool)expression.Value ? 1 : 0));
+                return new LiteralFragment((bool)expression.Value ? "1" : "0");
             else
             {
                 // use a parameter for non-numeric types so we get proper
@@ -276,7 +288,7 @@
 
             for (int i = 0; i < expression.Arguments.Count; i++)
             {
-                ColumnFragment col = null;
+                ColumnFragment col; 
 
                 SqlFragment fragment = expression.Arguments[i].Accept(this);
                 if (fragment is ColumnFragment)
@@ -424,19 +436,12 @@
             Debug.Assert(f is InputFragment);
 
             InputFragment inputFragment = f as InputFragment;
-            inputFragment.Name = name;
 
             if (inputFragment is TableFragment && type != null)
                 (inputFragment as TableFragment).Type = type;
 
-            SelectStatement select = inputFragment as SelectStatement;
             if (name != null)
-            {
-                if (select != null &&  !select.IsWrapped)
-                    scope.Add(name, select.From);
-                else
-                    scope.Add(name, inputFragment);
-            }
+                scope.Add(name, inputFragment);
 
             return inputFragment;
         }
@@ -497,25 +502,6 @@
             return true;
         }
 
-        ColumnFragment GetColumnFromPropertyTree(PropertyFragment fragment)
-        {
-            int lastIndex = fragment.Properties.Count-1;
-            SqlFragment currentFragment = scope.GetFragment(fragment.Properties[0]);
-            if (currentFragment != null)
-            {
-                for (int i = 1; i < fragment.Properties.Count; i++)
-                {
-                    SqlFragment f = (currentFragment as InputFragment).GetProperty(fragment.Properties[i]);
-                    if (f == null) break;
-                    currentFragment = f;
-                }
-                if (currentFragment is ColumnFragment)
-                    return currentFragment as ColumnFragment;
-            }
-            ColumnFragment col = new ColumnFragment(null, fragment.Properties[lastIndex]);
-            return col;
-        }
-
         #endregion
 
     }

=== modified file 'MySql.Data.Entity/Provider/Metadata.cs'
--- a/MySql.Data.Entity/Provider/Metadata.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Metadata.cs	2011-03-03 18:01:04 +0000
@@ -125,6 +125,20 @@
             }
         }
 
+        public static bool IsComparisonOperator(string op)
+        {
+            switch (op)
+            {
+                case "=":
+                case "<":
+                case ">":
+                case "<=":
+                case ">=":
+                case "!=": return true;
+                default: return false;
+            }
+        }
+
         public static string GetOperator(DbExpressionKind expressionKind)
         {
             switch (expressionKind)

=== modified file 'MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl'
--- a/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl	2010-07-19 18:30:42 +0000
+++ b/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl	2011-03-03 17:57:57 +0000
@@ -9,7 +9,7 @@
     <EntitySet Name="STables" EntityType="Self.Table">
       <DefiningQuery>
 		  SELECT /* Tables */
-		  CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+		  CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
 		  TABLE_CATALOG AS `Catalog`,
 		  TABLE_SCHEMA  AS `Schema`,
 		  TABLE_NAME    AS `Name`

=== modified file 'MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl'
--- a/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl	2010-07-19 18:30:42 +0000
+++ b/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl	2011-03-03 17:57:57 +0000
@@ -9,7 +9,7 @@
     <EntitySet Name="STables" EntityType="Self.Table">
       <DefiningQuery>
 		  SELECT /* Tables */
-		  CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+		  CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
 		  TABLE_CATALOG AS `Catalog`,
 		  TABLE_SCHEMA  AS `Schema`,
 		  TABLE_NAME    AS `Name`
@@ -22,8 +22,8 @@
     <EntitySet Name="STableColumns" EntityType="Self.TableColumn">
       <DefiningQuery>
         SELECT /* Table columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -52,7 +52,7 @@
     <EntitySet Name="SViews" EntityType="Self.View">
       <DefiningQuery>
         SELECT /* Views */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
         TABLE_CATALOG AS`CatalogName`,
         TABLE_SCHEMA AS `SchemaName`,
         TABLE_NAME AS `Name`,
@@ -65,8 +65,8 @@
     <EntitySet Name="SViewColumns" EntityType="Self.ViewColumn">
       <DefiningQuery>
         SELECT /* View columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -95,7 +95,7 @@
     <EntitySet Name="SFunctions" EntityType="Self.Function">
       <DefiningQuery>
         SELECT /* Functions */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`,
@@ -123,7 +123,7 @@
     <EntitySet Name="SProcedures" EntityType="Self.Procedure">
       <DefiningQuery>
         SELECT /* Procedures */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`
@@ -186,8 +186,8 @@
     <EntitySet Name="SConstraints" EntityType="Self.Constraint">
       <DefiningQuery>
         SELECT  /* Constraints */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         CONSTRAINT_NAME AS `Name`,
         CONSTRAINT_TYPE AS `ConstraintType`,
         0 AS `IsDeferrable`,
@@ -208,8 +208,8 @@
     <EntitySet Name="SConstraintColumns" EntityType="Self.ConstraintColumn">
       <DefiningQuery>
         SELECT  /* Constraint columns */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `ConstraintId`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `ColumnId`
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `ConstraintId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `ColumnId`
         FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA=schema()
       </DefiningQuery>
     </EntitySet>
@@ -230,7 +230,7 @@
     <EntitySet Name="SForeignKeyConstraints" EntityType="Self.ForeignKeyConstraint">
       <DefiningQuery>
         SELECT
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
         UPDATE_RULE AS `UpdateRule`,
         DELETE_RULE AS `DeleteRule`
         FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
@@ -240,10 +240,10 @@
     <EntitySet Name="SForeignKeys" EntityType="Self.ForeignKey">
       <DefiningQuery>
         SELECT
-        CONCAT('`', FC.CONSTRAINT_SCHEMA, '`.`', FC.CONSTRAINT_NAME, '`.`', FC.ORDINAL_POSITION, '`') AS `Id`,
-        CONCAT('`', PC.TABLE_SCHEMA, '`.`', PC.TABLE_NAME, '`.`', PC.COLUMN_NAME, '`') AS `ToColumnId`,
-        CONCAT('`', FC.TABLE_SCHEMA, '`.`', FC.TABLE_NAME, '`.`', FC.COLUMN_NAME, '`') AS `FromColumnId`,
-        CONCAT('`', FC.CONSTRAINT_SCHEMA, '`.`', FC.TABLE_NAME, '`.`', FC.CONSTRAINT_NAME, '`') AS `ConstraintId`,
+        CONCAT(FC.CONSTRAINT_SCHEMA, '.', FC.CONSTRAINT_NAME, '.', FC.ORDINAL_POSITION) AS `Id`,
+        CONCAT(PC.TABLE_SCHEMA, '.', PC.TABLE_NAME, '.', PC.COLUMN_NAME) AS `ToColumnId`,
+        CONCAT(FC.TABLE_SCHEMA, '.', FC.TABLE_NAME, '.', FC.COLUMN_NAME) AS `FromColumnId`,
+        CONCAT(FC.CONSTRAINT_SCHEMA, '.', FC.TABLE_NAME, '.', FC.CONSTRAINT_NAME) AS `ConstraintId`,
         FC.ORDINAL_POSITION AS `Ordinal`
         FROM
         INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC

=== modified file 'MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl'
--- a/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl	2010-07-19 18:30:42 +0000
+++ b/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl	2011-03-03 17:57:57 +0000
@@ -9,7 +9,7 @@
     <EntitySet Name="STables" EntityType="Self.Table">
       <DefiningQuery>
 		  SELECT /* Tables */
-		  CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+		  CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
 		  TABLE_CATALOG AS `Catalog`,
 		  TABLE_SCHEMA  AS `Schema`,
 		  TABLE_NAME    AS `Name`
@@ -22,8 +22,8 @@
     <EntitySet Name="STableColumns" EntityType="Self.TableColumn">
       <DefiningQuery>
         SELECT /* Table columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -52,7 +52,7 @@
     <EntitySet Name="SViews" EntityType="Self.View">
       <DefiningQuery>
         SELECT /* Views */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
         TABLE_CATALOG AS`CatalogName`,
         TABLE_SCHEMA AS `SchemaName`,
         TABLE_NAME AS `Name`,
@@ -65,8 +65,8 @@
     <EntitySet Name="SViewColumns" EntityType="Self.ViewColumn">
       <DefiningQuery>
         SELECT /* View columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -95,7 +95,7 @@
     <EntitySet Name="SFunctions" EntityType="Self.Function">
       <DefiningQuery>
         SELECT /* Functions */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`,
@@ -123,7 +123,7 @@
     <EntitySet Name="SProcedures" EntityType="Self.Procedure">
       <DefiningQuery>
         SELECT /* Procedures */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`
@@ -136,8 +136,8 @@
     <EntitySet Name="SFunctionParameters" EntityType="Self.Parameter">
       <DefiningQuery>
         SELECT
-        CONCAT('`', f.SPECIFIC_SCHEMA, '`.`', f.SPECIFIC_NAME, '`.`', f.PARAMETER_NAME, '`') AS `Id`,
-        CONCAT('`', f.SPECIFIC_SCHEMA, '`.`', f.SPECIFIC_NAME, '`') AS `ParentId`,
+        CONCAT(f.SPECIFIC_SCHEMA, '.', f.SPECIFIC_NAME, '.', f.PARAMETER_NAME) AS `Id`,
+        CONCAT(f.SPECIFIC_SCHEMA, '.', f.SPECIFIC_NAME) AS `ParentId`,
         f.PARAMETER_NAME AS `Name`,
         f.ORDINAL_POSITION `Ordinal`,
         f.DATA_TYPE AS `TypeName`,
@@ -168,8 +168,8 @@
     <EntitySet Name="SProcedureParameters" EntityType="Self.Parameter">
       <DefiningQuery>
         SELECT
-        CONCAT('`', f.SPECIFIC_SCHEMA, '`.`', f.SPECIFIC_NAME, '`.`', f.PARAMETER_NAME, '`') AS `Id`,
-        CONCAT('`', f.SPECIFIC_SCHEMA, '`.`', f.SPECIFIC_NAME, '`') AS `ParentId`,
+        CONCAT(f.SPECIFIC_SCHEMA, '.', f.SPECIFIC_NAME, '.', f.PARAMETER_NAME) AS `Id`,
+        CONCAT(f.SPECIFIC_SCHEMA, '.', f.SPECIFIC_NAME) AS `ParentId`,
         f.PARAMETER_NAME AS `Name`,
         f.ORDINAL_POSITION `Ordinal`,
         f.DATA_TYPE AS `TypeName`,
@@ -200,8 +200,8 @@
     <EntitySet Name="SConstraints" EntityType="Self.Constraint">
       <DefiningQuery>
         SELECT  /* Constraints */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         CONSTRAINT_NAME AS `Name`,
         CONSTRAINT_TYPE AS `ConstraintType`,
         0 AS `IsDeferrable`,
@@ -222,8 +222,8 @@
     <EntitySet Name="SConstraintColumns" EntityType="Self.ConstraintColumn">
       <DefiningQuery>
         SELECT  /* Constraint columns */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `ConstraintId`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `ColumnId`
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `ConstraintId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `ColumnId`
         FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA=schema()
       </DefiningQuery>
     </EntitySet>
@@ -244,7 +244,7 @@
     <EntitySet Name="SForeignKeyConstraints" EntityType="Self.ForeignKeyConstraint">
       <DefiningQuery>
         SELECT
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
         UPDATE_RULE AS `UpdateRule`,
         DELETE_RULE AS `DeleteRule`
         FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
@@ -254,10 +254,10 @@
     <EntitySet Name="SForeignKeys" EntityType="Self.ForeignKey">
       <DefiningQuery>
         SELECT
-        CONCAT('`', FC.CONSTRAINT_SCHEMA, '`.`', FC.CONSTRAINT_NAME, '`.`', FC.ORDINAL_POSITION, '`') AS `Id`,
-        CONCAT('`', PC.TABLE_SCHEMA, '`.`', PC.TABLE_NAME, '`.`', PC.COLUMN_NAME, '`') AS `ToColumnId`,
-        CONCAT('`', FC.TABLE_SCHEMA, '`.`', FC.TABLE_NAME, '`.`', FC.COLUMN_NAME, '`') AS `FromColumnId`,
-        CONCAT('`', FC.CONSTRAINT_SCHEMA, '`.`', FC.TABLE_NAME, '`.`', FC.CONSTRAINT_NAME, '`') AS `ConstraintId`,
+        CONCAT(FC.CONSTRAINT_SCHEMA, '.', FC.CONSTRAINT_NAME, '.', FC.ORDINAL_POSITION) AS `Id`,
+        CONCAT(PC.TABLE_SCHEMA, '.', PC.TABLE_NAME, '.', PC.COLUMN_NAME) AS `ToColumnId`,
+        CONCAT(FC.TABLE_SCHEMA, '.', FC.TABLE_NAME, '.', FC.COLUMN_NAME) AS `FromColumnId`,
+        CONCAT(FC.CONSTRAINT_SCHEMA, '.', FC.TABLE_NAME, '.', FC.CONSTRAINT_NAME) AS `ConstraintId`,
         FC.ORDINAL_POSITION AS `Ordinal`
         FROM
         INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC

=== modified file 'MySql.Data.Entity/Provider/Statements/SelectStatement.cs'
--- a/MySql.Data.Entity/Provider/Statements/SelectStatement.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Statements/SelectStatement.cs	2011-03-03 18:01:04 +0000
@@ -62,12 +62,6 @@
             OrderBy.Add(f);
         }
 
-        public override SqlFragment GetProperty(string propertyName)
-        {
-            if (From == null || From.Name != propertyName) return null;
-            return From;
-        }
-
         public override void WriteSql(StringBuilder sql)
         {
             if (IsWrapped)
@@ -75,6 +69,7 @@
             sql.Append("SELECT");
             if (IsDistinct)
                 sql.Append(" DISTINCT ");
+
             WriteList(Columns, sql);
 
             if (From != null)
@@ -92,11 +87,7 @@
                 sql.Append("\r\n GROUP BY ");
                 WriteList(GroupBy, sql);
             }
-            if (OrderBy != null)
-            {
-                sql.Append("\r\n ORDER BY ");
-                WriteList(OrderBy, sql);
-            }
+            WriteOrderBy(sql);
             if (Limit != null || Skip != null)
             {
                 sql.Append(" LIMIT ");
@@ -115,6 +106,13 @@
             }
         }
 
+        private void WriteOrderBy(StringBuilder sql)
+        {
+            if (OrderBy == null) return;
+            sql.Append("\r\n ORDER BY ");
+            WriteList(OrderBy, sql);
+        }
+
         public override void Wrap(Scope scope)
         {
             base.Wrap(scope);

=== modified file 'MySql.Data.Entity/Tests/AggregateOperators.cs'
--- a/MySql.Data.Entity/Tests/AggregateOperators.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/AggregateOperators.cs	2011-03-03 18:01:04 +0000
@@ -29,25 +29,13 @@
 using System.Data.Common;
 using NUnit.Framework;
 using System.Data.Objects;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
 	[TestFixture]
 	public class AggregateOperators : BaseEdmTest
 	{
-        public AggregateOperators()
-            : base()
-        {
-        }
-
-        private EntityConnection GetEntityConnection()
-        {
-            string connectionString = String.Format(
-                "metadata=TestDB.csdl|TestDB.msl|TestDB.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
-            EntityConnection connection = new EntityConnection(connectionString);
-            return connection;
-        }
-
         [Test]
         public void CountSimple()
         {
@@ -56,8 +44,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE Count(t.Id) FROM Toys AS t";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE Count(t.Id) FROM Toys AS t";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.CountSimple);
 
                 foreach (int count in q)
                     Assert.AreEqual(trueCount, count);
@@ -72,8 +63,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE BigCount(t.Id) FROM Toys AS t";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE BigCount(t.Id) FROM Toys AS t";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.BigCountSimple);
 
                 foreach (int count in q)
                     Assert.AreEqual(trueCount, count);
@@ -88,8 +82,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE Count(t.Id) FROM Toys AS t WHERE t.MinAge > 3";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE Count(t.Id) FROM Toys AS t WHERE t.MinAge > 3";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.CountWithPredicate);
 
                 foreach (int count in q)
                     Assert.AreEqual(trueCount, count);
@@ -104,8 +101,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE MIN(t.MinAge) FROM Toys AS t";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE MIN(t.MinAge) FROM Toys AS t";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MinSimple);
 
                 foreach (int age in q)
                     Assert.AreEqual(trueMin, age);
@@ -120,8 +120,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT Min(o.Freight) FROM Orders AS o WHERE o.Store.Id = 2";
-                ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(sql);
+                string eSql = "SELECT Min(o.Freight) FROM Orders AS o WHERE o.Store.Id = 2";
+                ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MinWithPredicate);
 
                 foreach (DbDataRecord r in q)
                 {
@@ -140,8 +143,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE Min(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE Min(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MinWithGrouping);
 
                 int i = 0;
                 foreach (double freight in q)
@@ -157,8 +163,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE MAX(t.MinAge) FROM Toys AS t";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE MAX(t.MinAge) FROM Toys AS t";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MaxSimple);
 
                 foreach (int max in q)
                     Assert.AreEqual(trueMax, max);
@@ -173,8 +182,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT MAX(o.Freight) FROM Orders AS o WHERE o.Store.Id = 1";
-                ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(sql);
+                string eSql = "SELECT MAX(o.Freight) FROM Orders AS o WHERE o.Store.Id = 1";
+                ObjectQuery<DbDataRecord> q = context.CreateQuery<DbDataRecord>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MaxWithPredicate);
 
                 foreach (DbDataRecord r in q)
                     Assert.AreEqual(freight, r.GetDouble(0));
@@ -191,8 +203,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE MAX(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE MAX(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MaxWithGrouping);
 
                 int i = 0;
                 foreach (double freight in q)
@@ -208,8 +223,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE Avg(t.MinAge) FROM Toys AS t";
-                ObjectQuery<Decimal> q = context.CreateQuery<Decimal>(sql);
+                string eSql = "SELECT VALUE Avg(t.MinAge) FROM Toys AS t";
+                ObjectQuery<Decimal> q = context.CreateQuery<Decimal>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.AverageSimple);
 
                 foreach (Decimal r in q)
                     Assert.AreEqual(avgAge, r);
@@ -224,8 +242,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE AVG(o.Freight) FROM Orders AS o WHERE o.Store.Id = 3";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE AVG(o.Freight) FROM Orders AS o WHERE o.Store.Id = 3";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.AverageWithPredicate);
 
                 foreach (Double r in q)
                     Assert.AreEqual(Convert.ToInt32(freight), Convert.ToInt32(r));
@@ -242,8 +263,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE AVG(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE AVG(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.AverageWithGrouping);
 
                 int i = 0;
                 foreach (double freight in q)
@@ -259,8 +283,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE Sum(t.MinAge) FROM Toys AS t";
-                ObjectQuery<Int32> q = context.CreateQuery<Int32>(sql);
+                string eSql = "SELECT VALUE Sum(t.MinAge) FROM Toys AS t";
+                ObjectQuery<Int32> q = context.CreateQuery<Int32>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.SumSimple);
 
                 foreach (int r in q)
                     Assert.AreEqual(sumAge, r);
@@ -275,8 +302,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE SUM(o.Freight) FROM Orders AS o WHERE o.Store.Id = 2";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE SUM(o.Freight) FROM Orders AS o WHERE o.Store.Id = 2";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.SumWithPredicate);
 
                 foreach (Double r in q)
                     Assert.AreEqual(freight, r);
@@ -293,8 +323,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE SUM(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
-                ObjectQuery<Double> q = context.CreateQuery<Double>(sql);
+                string eSql = "SELECT VALUE SUM(o.Freight) FROM Orders AS o GROUP BY o.Store.Id";
+                ObjectQuery<Double> q = context.CreateQuery<Double>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.SumWithGrouping);
 
                 int i = 0;
                 foreach (double freight in q)
@@ -312,9 +345,12 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = @"SELECT VALUE s FROM Stores AS s WHERE s.Id = 
+                string eSql = @"SELECT VALUE s FROM Stores AS s WHERE s.Id = 
                                 MAX(SELECT VALUE o.Store.Id FROM Orders As o)";
-                ObjectQuery<Store> q = context.CreateQuery<Store>(sql);
+                ObjectQuery<Store> q = context.CreateQuery<Store>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MaxInSubQuery1);
 
                 int i = 0;
                 foreach (Store s in q)
@@ -332,9 +368,12 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = @"SELECT VALUE s FROM Stores AS s WHERE s.Id = 
+                string eSql = @"SELECT VALUE s FROM Stores AS s WHERE s.Id = 
                                 ANYELEMENT(SELECT VALUE MAX(o.Store.Id) FROM Orders As o)";
-                ObjectQuery<Store> q = context.CreateQuery<Store>(sql);
+                ObjectQuery<Store> q = context.CreateQuery<Store>(eSql);
+
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.MaxInSubQuery2);
 
                 int i = 0;
                 foreach (Store s in q)

=== modified file 'MySql.Data.Entity/Tests/BaseEdmTest.cs'
--- a/MySql.Data.Entity/Tests/BaseEdmTest.cs	2010-10-04 18:08:24 +0000
+++ b/MySql.Data.Entity/Tests/BaseEdmTest.cs	2011-03-03 18:02:14 +0000
@@ -36,6 +36,8 @@
 using System.Xml;
 using System.IO;
 using NUnit.Framework;
+using System.Text;
+using System.Data.EntityClient;
 
 namespace MySql.Data.Entity.Tests
 {
@@ -105,5 +107,26 @@
             MySqlCommand cmd = new MySqlCommand("DROP DATABASE IF EXISTS `modeldb`", rootConn);
             cmd.ExecuteNonQuery();
         }
+
+        private EntityConnection GetEntityConnection()
+        {
+            string connectionString = String.Format(
+                "metadata=TestDB.csdl|TestDB.msl|TestDB.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
+            EntityConnection connection = new EntityConnection(connectionString);
+            return connection;
+        }
+
+        protected void CheckSql(string sql, string refSql)
+        {
+            StringBuilder str1 = new StringBuilder();
+            StringBuilder str2 = new StringBuilder();
+            foreach (char c in sql)
+                if (!Char.IsWhiteSpace(c))
+                    str1.Append(c);
+            foreach (char c in refSql)
+                if (!Char.IsWhiteSpace(c))
+                    str2.Append(c);
+            Assert.AreEqual(0, String.Compare(str1.ToString(), str2.ToString(), true));
+        }
     }
 }

=== modified file 'MySql.Data.Entity/Tests/CanonicalFunctions.cs'
--- a/MySql.Data.Entity/Tests/CanonicalFunctions.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/CanonicalFunctions.cs	2011-03-03 18:01:04 +0000
@@ -35,11 +35,6 @@
 	[TestFixture]
 	public class CanonicalFunctions : BaseEdmTest
 	{
-        public CanonicalFunctions()
-            : base()
-        {
-        }
-
         private EntityConnection GetEntityConnection()
         {
             string connectionString = String.Format(

=== modified file 'MySql.Data.Entity/Tests/InsertTests.cs'
--- a/MySql.Data.Entity/Tests/InsertTests.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/InsertTests.cs	2011-03-03 18:01:04 +0000
@@ -35,12 +35,6 @@
     [TestFixture]
     public class InsertTests : BaseEdmTest
     {
-        public InsertTests()
-            : base()
-        {
-            csAdditions += ";logging=true;";
-        }
-
         [Test]
         public void InsertSingleRow()
         {

=== modified file 'MySql.Data.Entity/Tests/JoinTests.cs'
--- a/MySql.Data.Entity/Tests/JoinTests.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/JoinTests.cs	2011-03-03 18:01:04 +0000
@@ -30,6 +30,7 @@
 using System.Data.Common;
 using System.Data.Objects;
 using System.Linq;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
@@ -57,6 +58,9 @@
                             authorName = a.Name
                         };
 
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.SimpleJoin);
+
                 int i = 0;
                 foreach (var o in q)
                     Assert.AreEqual(dt.Rows[i++][0], o.bookId);
@@ -86,6 +90,9 @@
                             authorName = a.Name
                         };
 
+                string sql = q.ToTraceString();
+                CheckSql(sql, SQLSyntax.SimpleJoinWithPredicate);
+
                 int i = 0;
                 foreach (var o in q)
                     Assert.AreEqual(dt.Rows[i++][0], o.bookId);

=== modified file 'MySql.Data.Entity/Tests/MySql.Data.Entity.Tests.csproj'
--- a/MySql.Data.Entity/Tests/MySql.Data.Entity.Tests.csproj	2010-12-06 21:35:13 +0000
+++ b/MySql.Data.Entity/Tests/MySql.Data.Entity.Tests.csproj	2011-03-03 18:02:14 +0000
@@ -112,6 +112,11 @@
     <Compile Include="ProceduresAndFunctions.cs" />
     <Compile Include="JoinTests.cs" />
     <Compile Include="SchemaInformation.cs" />
+    <Compile Include="Properties\SQLSyntax.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>SQLSyntax.resx</DependentUpon>
+    </Compile>
     <Compile Include="TestModel.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
@@ -149,6 +154,10 @@
     <EmbeddedResource Include="Properties\Resources.resx">
       <SubType>Designer</SubType>
     </EmbeddedResource>
+    <EmbeddedResource Include="Properties\SQLSyntax.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>SQLSyntax.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <WCFMetadata Include="Service References" />

=== modified file 'MySql.Data.Entity/Tests/OrderingAndGrouping.cs'
--- a/MySql.Data.Entity/Tests/OrderingAndGrouping.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/OrderingAndGrouping.cs	2011-03-03 18:01:04 +0000
@@ -29,29 +29,13 @@
 using System.Data.Common;
 using NUnit.Framework;
 using System.Data.Objects;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
-	/// <summary>
-	/// Summary description for BlobTests.
-	/// </summary>
     [TestFixture]
     public class OrderingAndGrouping : BaseEdmTest
     {
-        public OrderingAndGrouping()
-            : base()
-        {
-            csAdditions += ";logging=true;";
-        }
-
-        private EntityConnection GetEntityConnection()
-        {
-            string connectionString = String.Format(
-                "metadata=TestDB.csdl|TestDB.msl|TestDB.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
-            EntityConnection connection = new EntityConnection(connectionString);
-            return connection;
-        }
-
         [Test]
         public void OrderBySimple()
         {
@@ -62,8 +46,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE c FROM Companies AS c ORDER BY c.Name";
-                ObjectQuery<Company> query = context.CreateQuery<Company>(sql);
+                string eSql = "SELECT VALUE c FROM Companies AS c ORDER BY c.Name";
+                ObjectQuery<Company> query = context.CreateQuery<Company>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.OrderBySimple);
 
                 int i = 0;
                 foreach (Company c in query)
@@ -84,8 +71,11 @@
                     DataTable dt = new DataTable();
                     da.Fill(dt);
 
-                    string sql = "SELECT VALUE c FROM Companies AS c WHERE c.NumEmployees > 100 ORDER BY c.Name";
-                    ObjectQuery<Company> query = context.CreateQuery<Company>(sql);
+                    string eSql = "SELECT VALUE c FROM Companies AS c WHERE c.NumEmployees > 100 ORDER BY c.Name";
+                    ObjectQuery<Company> query = context.CreateQuery<Company>(eSql);
+
+                    string sql = query.ToTraceString();
+                    CheckSql(sql, SQLSyntax.OrderByWithPredicate);
 
                     int i = 0;
                     foreach (Company c in query)

=== modified file 'MySql.Data.Entity/Tests/Paging.cs'
--- a/MySql.Data.Entity/Tests/Paging.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/Paging.cs	2011-03-03 18:01:04 +0000
@@ -30,25 +30,13 @@
 using System.Data.Common;
 using NUnit.Framework;
 using System.Data.Objects;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
 	[TestFixture]
 	public class Paging : BaseEdmTest
 	{
-        public Paging()
-            : base()
-        {
-        }
-
-        private EntityConnection GetEntityConnection()
-        {
-            string connectionString = String.Format(
-                "metadata=TestDB.csdl|TestDB.msl|TestDB.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
-            EntityConnection connection = new EntityConnection(connectionString);
-            return connection;
-        }
-
         [Test]
         public void Top()
         {
@@ -60,6 +48,9 @@
 
                 int i = 0;
                 var query = context.Companies.Top("2");
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.Top);
+
                 foreach (Company c in query)
                 {
                     Assert.AreEqual(dt.Rows[i++]["id"], c.Id);
@@ -78,6 +69,9 @@
 
                 int i = 0;
                 var query = context.Companies.Skip("it.Id", "3");
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.Skip);
+
                 foreach (Company c in query)
                 {
                     Assert.AreEqual(dt.Rows[i++]["id"], c.Id);
@@ -96,6 +90,9 @@
 
                 int i = 0;
                 var query = context.Companies.Skip("it.Id", "2").Top("2");
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SkipAndTakeSimple);
+
                 foreach (Company c in query)
                 {
                     Assert.AreEqual(dt.Rows[i++]["id"], c.Id);
@@ -117,7 +114,9 @@
                 da.Fill(dt);
 
                 int i = 0;
-                var query = context.Companies.OrderByDescending(q => q.Name).Skip(2).Take(2).ToList();
+                var query = context.Companies.OrderByDescending(q => q.Name).Skip(2).Take(2);
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SkipAndTakeWithOrdering);
                 foreach (Company c in query)
                     Assert.AreEqual(dt.Rows[i++]["Name"], c.Name);
             }

=== added file 'MySql.Data.Entity/Tests/Properties/SQLSyntax.Designer.cs'
--- a/MySql.Data.Entity/Tests/Properties/SQLSyntax.Designer.cs	1970-01-01 00:00:00 +0000
+++ b/MySql.Data.Entity/Tests/Properties/SQLSyntax.Designer.cs	2011-03-03 17:54:43 +0000
@@ -0,0 +1,719 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.5420
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MySql.Data.Entity.Tests.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class SQLSyntax {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal SQLSyntax() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MySql.Data.Entity.Tests.Properties.SQLSyntax", typeof(SQLSyntax).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.Age
+        ///FROM Authors AS Extent1
+        /// WHERE NOT EXISTS(SELECT
+        ///1 AS C1
+        ///FROM Books AS Extent2
+        /// WHERE Extent1.Id = Extent2.Author_id).
+        /// </summary>
+        internal static string Any {
+            get {
+                return ResourceManager.GetString("Any", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Avg(Extent1.MinAge) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string AverageSimple {

+            get {
+                return ResourceManager.GetString("AverageSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Avg(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// GROUP BY 
+        ///Extent2.Id) AS GroupBy1.
+        /// </summary>
+        internal static string AverageWithGrouping {
+            get {
+                return ResourceManager.GetString("AverageWithGrouping", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Avg(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// WHERE Extent2.Id = 3) AS GroupBy1.
+        /// </summary>
+        internal static string AverageWithPredicate {
+            get {
+                return ResourceManager.GetString("AverageWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Count(Extent1.Id) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string BigCountSimple {
+            get {
+                return ResourceManager.GetString("BigCountSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Count(Extent1.Id) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string CountSimple {
+            get {
+                return ResourceManager.GetString("CountSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Count(Extent1.Id) AS A1
+        ///FROM Toys AS Extent1
+        /// WHERE Extent1.MinAge &gt; 3) AS GroupBy1.
+        /// </summary>
+        internal static string CountWithPredicate {
+            get {
+                return ResourceManager.GetString("CountWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1) AS Project1
+        /// WHERE EXISTS(SELECT
+        ///1 AS C1
+        ///FROM Toys AS Extent2
+        /// WHERE (Project1.Id = Extent2.SupplierId) AND (Extent2.MinAge &lt; 4)).
+        /// </summary>
+        internal static string Exists {
+            get {
+                return ResourceManager.GetString("Exists", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode
+        ///FROM Stores AS Extent1 INNER JOIN (SELECT
+        ///MAX(Extent3.Id) AS A1
+        ///FROM Orders AS Extent2 LEFT OUTER JOIN Stores AS Extent3 ON Extent2.StoreId = Extent3.Id) AS GroupBy1 ON Extent1.Id = GroupBy1.A1.
+        /// </summary>
+        internal static string MaxInSubQuery1 {
+            get {
+                return ResourceManager.GetString("MaxInSubQuery1", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode
+        ///FROM Stores AS Extent1 INNER JOIN (SELECT
+        ///MAX(Extent3.Id) AS A1
+        ///FROM Orders AS Extent2 LEFT OUTER JOIN Stores AS Extent3 ON Extent2.StoreId = Extent3.Id) AS GroupBy1 ON Extent1.Id = GroupBy1.A1.
+        /// </summary>
+        internal static string MaxInSubQuery2 {
+            get {
+                return ResourceManager.GetString("MaxInSubQuery2", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Max(Extent1.MinAge) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string MaxSimple {
+            get {
+                return ResourceManager.GetString("MaxSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Max(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// GROUP BY 
+        ///Extent2.Id) AS GroupBy1.
+        /// </summary>
+        internal static string MaxWithGrouping {
+            get {
+                return ResourceManager.GetString("MaxWithGrouping", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///GroupBy1.A1 AS C2
+        ///FROM (SELECT
+        ///Max(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// WHERE Extent2.Id = 1) AS GroupBy1.
+        /// </summary>
+        internal static string MaxWithPredicate {
+            get {
+                return ResourceManager.GetString("MaxWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Min(Extent1.MinAge) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string MinSimple {
+            get {
+                return ResourceManager.GetString("MinSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Min(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// GROUP BY 
+        ///Extent2.Id) AS GroupBy1.
+        /// </summary>
+        internal static string MinWithGrouping {
+            get {
+                return ResourceManager.GetString("MinWithGrouping", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///GroupBy1.A1 AS C2
+        ///FROM (SELECT
+        ///Min(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// WHERE Extent2.Id = 2) AS GroupBy1.
+        /// </summary>
+        internal static string MinWithPredicate {
+            get {
+                return ResourceManager.GetString("MinWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1) AS Project1
+        /// ORDER BY 
+        ///Project1.Name ASC.
+        /// </summary>
+        internal static string OrderBySimple {
+            get {
+                return ResourceManager.GetString("OrderBySimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1
+        /// WHERE Extent1.NumEmployees &gt; 100) AS Project1
+        /// ORDER BY 
+        ///Project1.Name ASC.
+        /// </summary>
+        internal static string OrderByWithPredicate {
+            get {
+                return ResourceManager.GetString("OrderByWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.LastName
+        ///FROM Employees AS Extent1 LEFT OUTER JOIN SalariedEmployees AS Extent2 ON Extent1.Id = Extent2.EmployeeId
+        /// WHERE Extent1.Age &gt; 20.
+        /// </summary>
+        internal static string SelectWithComplexType {
+            get {
+                return ResourceManager.GetString("SelectWithComplexType", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent2.Name AS Name1
+        ///FROM Books AS Extent1 INNER JOIN Authors AS Extent2 ON (Extent1.Author_id = Extent2.Id) OR ((Extent1.Author_id IS  NULL) AND (Extent2.Id IS  NULL)).
+        /// </summary>
+        internal static string SimpleJoin {
+            get {
+                return ResourceManager.GetString("SimpleJoin", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent2.Name AS Name1
+        ///FROM Books AS Extent1 INNER JOIN Authors AS Extent2 ON (Extent1.Author_id = Extent2.Id) OR ((Extent1.Author_id IS  NULL) AND (Extent2.Id IS  NULL))
+        /// WHERE Extent1.Pages &gt; 300.
+        /// </summary>
+        internal static string SimpleJoinWithPredicate {
+            get {
+                return ResourceManager.GetString("SimpleJoinWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.MinAge, 
+        ///Extent1.SupplierId
+        ///FROM Toys AS Extent1.
+        /// </summary>
+        internal static string SimpleSelect {
+            get {
+                return ResourceManager.GetString("SimpleSelect", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.MinAge, 
+        ///Extent1.SupplierId
+        ///FROM Toys AS Extent1
+        /// WHERE Extent1.MinAge = 4.
+        /// </summary>
+        internal static string SimpleSelectWithFilter {
+            get {
+                return ResourceManager.GetString("SimpleSelectWithFilter", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.MinAge, 
+        ///Extent1.SupplierId
+        ///FROM Toys AS Extent1
+        /// WHERE Extent1.MinAge &gt; @age.
+        /// </summary>
+        internal static string SimpleSelectWithParam {
+            get {
+                return ResourceManager.GetString("SimpleSelectWithParam", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1) AS Project1
+        /// ORDER BY 
+        ///Project1.Id ASC LIMIT 3,18446744073709551615.
+        /// </summary>
+        internal static string Skip {
+            get {
+                return ResourceManager.GetString("Skip", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1) AS Project1
+        /// ORDER BY 
+        ///Project1.Id ASC LIMIT 2,2.
+        /// </summary>
+        internal static string SkipAndTakeSimple {
+            get {
+                return ResourceManager.GetString("SkipAndTakeSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Project1.Id, 
+        ///Project1.Name, 
+        ///Project1.DateBegan, 
+        ///Project1.NumEmployees, 
+        ///Project1.C1, 
+        ///Project1.Address, 
+        ///Project1.City, 
+        ///Project1.State, 
+        ///Project1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1) AS Project1
+        /// ORDER BY 
+        ///Project1.Name DESC LIMIT 2,2.
+        /// </summary>
+        internal static string SkipAndTakeWithOrdering {
+            get {
+                return ResourceManager.GetString("SkipAndTakeWithOrdering", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Sum(Extent1.MinAge) AS A1
+        ///FROM Toys AS Extent1) AS GroupBy1.
+        /// </summary>
+        internal static string SumSimple {
+            get {
+                return ResourceManager.GetString("SumSimple", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///SUM(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// GROUP BY 
+        ///Extent2.Id) AS GroupBy1.
+        /// </summary>
+        internal static string SumWithGrouping {
+            get {
+                return ResourceManager.GetString("SumWithGrouping", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///GroupBy1.A1 AS C1
+        ///FROM (SELECT
+        ///Sum(Extent1.Freight) AS A1
+        ///FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+        /// WHERE Extent2.Id = 2) AS GroupBy1.
+        /// </summary>
+        internal static string SumWithPredicate {
+            get {
+                return ResourceManager.GetString("SumWithPredicate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Limit1.Id, 
+        ///Limit1.Name, 
+        ///Limit1.DateBegan, 
+        ///Limit1.NumEmployees, 
+        ///Limit1.C1, 
+        ///Limit1.Address, 
+        ///Limit1.City, 
+        ///Limit1.State, 
+        ///Limit1.ZipCode
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode, 
+        ///1 AS C1
+        ///FROM Companies AS Extent1 LIMIT 2) AS Limit1.
+        /// </summary>
+        internal static string Top {
+            get {
+                return ResourceManager.GetString("Top", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///UnionAll1.C1, 
+        ///UnionAll1.Id AS C2, 
+        ///UnionAll1.Name AS C3
+        ///FROM (SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name
+        ///FROM Toys AS Extent1 UNION ALL SELECT
+        ///1 AS C1, 
+        ///Extent2.Id, 
+        ///Extent2.Name
+        ///FROM Companies AS Extent2) AS UnionAll1.
+        /// </summary>
+        internal static string UnionAll {
+            get {
+                return ResourceManager.GetString("UnionAll", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.DateBegan, 
+        ///Extent1.NumEmployees, 
+        ///1 AS C1, 
+        ///Extent1.Address, 
+        ///Extent1.City, 
+        ///Extent1.State, 
+        ///Extent1.ZipCode
+        ///FROM Companies AS Extent1
+        /// WHERE Extent1.City = @gp1.
+        /// </summary>
+        internal static string WhereLiteralOnRelation {
+            get {
+                return ResourceManager.GetString("WhereLiteralOnRelation", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Extent1.Id, 
+        ///Extent1.Name, 
+        ///Extent1.MinAge, 
+        ///Extent1.SupplierId
+        ///FROM Toys AS Extent1 INNER JOIN Companies AS Extent2 ON Extent1.SupplierId = Extent2.Id
+        /// WHERE Extent2.State = @gp1.
+        /// </summary>
+        internal static string WhereWithRelatedEntities1 {
+            get {
+                return ResourceManager.GetString("WhereWithRelatedEntities1", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to SELECT
+        ///1 AS C1, 
+        ///Filter1.Id, 
+        ///Filter1.Name, 
+        ///Filter1.MinAge, 

+        ///Filter1.SupplierId
+        ///FROM (SELECT
+        ///Extent1.Id, 
+        ///Extent1.SupplierId, 
+        ///Extent1.Name, 
+        ///Extent1.MinAge, 
+        ///Extent2.Id AS Id1, 
+        ///Extent2.Name AS Name1, 
+        ///Extent2.DateBegan, 
+        ///Extent2.NumEmployees, 
+        ///Extent2.Address, 
+        ///Extent2.City, 
+        ///Extent2.State, 
+        ///Extent2.ZipCode
+        ///FROM Toys AS Extent1 LEFT OUTER JOIN Companies AS Extent2 ON Extent1.SupplierId = Extent2.Id
+        /// WHERE Extent2.State != @gp1) AS Filter1 LEFT OUTER JOIN Companies AS Extent3 ON Filter [rest of string was truncated]&quot;;.
+        /// </summary>
+        internal static string WhereWithRelatedEntities2 {
+            get {
+                return ResourceManager.GetString("WhereWithRelatedEntities2", resourceCulture);
+            }
+        }
+    }
+}

=== added file 'MySql.Data.Entity/Tests/Properties/SQLSyntax.resx'
--- a/MySql.Data.Entity/Tests/Properties/SQLSyntax.resx	1970-01-01 00:00:00 +0000
+++ b/MySql.Data.Entity/Tests/Properties/SQLSyntax.resx	2011-03-03 17:54:43 +0000
@@ -0,0 +1,567 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <data name="Any" xml:space="preserve">
+    <value>SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.Age
+FROM Authors AS Extent1
+ WHERE NOT EXISTS(SELECT
+1 AS C1
+FROM Books AS Extent2
+ WHERE Extent1.Id = Extent2.Author_id)</value>
+  </data>
+  <data name="AverageSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Avg(Extent1.MinAge) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="AverageWithGrouping" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Avg(Extent1.Freight) AS A1
+FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ GROUP BY 
+Extent2.Id) AS GroupBy1</value>
+  </data>
+  <data name="AverageWithPredicate" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Avg(Extent1.Freight) AS A1
+FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ WHERE Extent2.Id = 3) AS GroupBy1</value>
+  </data>
+  <data name="BigCountSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Count(Extent1.Id) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="CountSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Count(Extent1.Id) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="CountWithPredicate" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Count(Extent1.Id) AS A1
+FROM Toys AS Extent1
+ WHERE Extent1.MinAge &gt; 3) AS GroupBy1</value>
+  </data>
+  <data name="Exists" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1) AS Project1
+ WHERE EXISTS(SELECT
+1 AS C1
+FROM Toys AS Extent2
+ WHERE (Project1.Id = Extent2.SupplierId) AND (Extent2.MinAge &lt; 4))</value>
+  </data>
+  <data name="MaxInSubQuery1" xml:space="preserve">
+    <value>SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode
+FROM Stores AS Extent1 INNER JOIN (SELECT
+MAX(Extent3.Id) AS A1
+FROM Orders AS Extent2 LEFT OUTER JOIN Stores AS Extent3 ON Extent2.StoreId = Extent3.Id) AS GroupBy1 ON Extent1.Id = GroupBy1.A1</value>
+  </data>
+  <data name="MaxInSubQuery2" xml:space="preserve">
+    <value>SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode
+FROM Stores AS Extent1 INNER JOIN (SELECT
+MAX(Extent3.Id) AS A1
+FROM Orders AS Extent2 LEFT OUTER JOIN Stores AS Extent3 ON Extent2.StoreId = Extent3.Id) AS GroupBy1 ON Extent1.Id = GroupBy1.A1</value>
+  </data>
+  <data name="MaxSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Max(Extent1.MinAge) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="MaxWithGrouping" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Max(Extent1.Freight) AS A1
+FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ GROUP BY 
+Extent2.Id) AS GroupBy1</value>
+  </data>
+  <data name="MaxWithPredicate" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+GroupBy1.A1 AS C2
+FROM (SELECT
+Max(Extent1.Freight) AS A1
+FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ WHERE Extent2.Id = 1) AS GroupBy1</value>
+  </data>
+  <data name="MinSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Min(Extent1.MinAge) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="MinWithGrouping" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Min(Extent1.Freight) AS A1
+FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ GROUP BY 
+Extent2.Id) AS GroupBy1</value>
+  </data>
+  <data name="MinWithPredicate" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+GroupBy1.A1 AS C2
+FROM (SELECT
+Min(Extent1.Freight) AS A1
+FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ WHERE Extent2.Id = 2) AS GroupBy1</value>
+  </data>
+  <data name="OrderBySimple" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1) AS Project1
+ ORDER BY 
+Project1.Name ASC</value>
+  </data>
+  <data name="OrderByWithPredicate" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1
+ WHERE Extent1.NumEmployees &gt; 100) AS Project1
+ ORDER BY 
+Project1.Name ASC</value>
+  </data>
+  <data name="SelectWithComplexType" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.LastName
+FROM Employees AS Extent1 LEFT OUTER JOIN SalariedEmployees AS Extent2 ON Extent1.Id = Extent2.EmployeeId
+ WHERE Extent1.Age &gt; 20</value>
+  </data>
+  <data name="SimpleJoin" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 

+Extent2.Name AS Name1
+FROM Books AS Extent1 INNER JOIN Authors AS Extent2 ON (Extent1.Author_id = Extent2.Id) OR ((Extent1.Author_id IS  NULL) AND (Extent2.Id IS  NULL))</value>
+  </data>
+  <data name="SimpleJoinWithPredicate" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 
+Extent2.Name AS Name1
+FROM Books AS Extent1 INNER JOIN Authors AS Extent2 ON (Extent1.Author_id = Extent2.Id) OR ((Extent1.Author_id IS  NULL) AND (Extent2.Id IS  NULL))
+ WHERE Extent1.Pages &gt; 300</value>
+  </data>
+  <data name="SimpleSelect" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 
+Extent1.MinAge, 
+Extent1.SupplierId
+FROM Toys AS Extent1</value>
+  </data>
+  <data name="SimpleSelectWithFilter" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 
+Extent1.MinAge, 
+Extent1.SupplierId
+FROM Toys AS Extent1
+ WHERE Extent1.MinAge = 4</value>
+  </data>
+  <data name="SimpleSelectWithParam" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 
+Extent1.MinAge, 
+Extent1.SupplierId
+FROM Toys AS Extent1
+ WHERE Extent1.MinAge &gt; @age</value>
+  </data>
+  <data name="Skip" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1) AS Project1
+ ORDER BY 
+Project1.Id ASC LIMIT 3,18446744073709551615</value>
+  </data>
+  <data name="SkipAndTakeSimple" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1) AS Project1
+ ORDER BY 
+Project1.Id ASC LIMIT 2,2</value>
+  </data>
+  <data name="SkipAndTakeWithOrdering" xml:space="preserve">
+    <value>SELECT
+Project1.Id, 
+Project1.Name, 
+Project1.DateBegan, 
+Project1.NumEmployees, 
+Project1.C1, 
+Project1.Address, 
+Project1.City, 
+Project1.State, 
+Project1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1) AS Project1
+ ORDER BY 
+Project1.Name DESC LIMIT 2,2</value>
+  </data>
+  <data name="SumSimple" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Sum(Extent1.MinAge) AS A1
+FROM Toys AS Extent1) AS GroupBy1</value>
+  </data>
+  <data name="SumWithGrouping" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+SUM(Extent1.Freight) AS A1
+FROM Orders AS Extent1 LEFT OUTER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ GROUP BY 
+Extent2.Id) AS GroupBy1</value>
+  </data>
+  <data name="SumWithPredicate" xml:space="preserve">
+    <value>SELECT
+GroupBy1.A1 AS C1
+FROM (SELECT
+Sum(Extent1.Freight) AS A1
+FROM Orders AS Extent1 INNER JOIN Stores AS Extent2 ON Extent1.StoreId = Extent2.Id
+ WHERE Extent2.Id = 2) AS GroupBy1</value>
+  </data>
+  <data name="Top" xml:space="preserve">
+    <value>SELECT
+Limit1.Id, 
+Limit1.Name, 
+Limit1.DateBegan, 
+Limit1.NumEmployees, 
+Limit1.C1, 
+Limit1.Address, 
+Limit1.City, 
+Limit1.State, 
+Limit1.ZipCode
+FROM (SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode, 
+1 AS C1
+FROM Companies AS Extent1 LIMIT 2) AS Limit1</value>
+  </data>
+  <data name="UnionAll" xml:space="preserve">
+    <value>SELECT
+UnionAll1.C1, 
+UnionAll1.Id AS C2, 
+UnionAll1.Name AS C3
+FROM (SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name
+FROM Toys AS Extent1 UNION ALL SELECT
+1 AS C1, 
+Extent2.Id, 
+Extent2.Name
+FROM Companies AS Extent2) AS UnionAll1</value>
+  </data>
+  <data name="WhereLiteralOnRelation" xml:space="preserve">
+    <value>SELECT
+Extent1.Id, 
+Extent1.Name, 
+Extent1.DateBegan, 
+Extent1.NumEmployees, 
+1 AS C1, 
+Extent1.Address, 
+Extent1.City, 
+Extent1.State, 
+Extent1.ZipCode
+FROM Companies AS Extent1
+ WHERE Extent1.City = @gp1</value>
+  </data>
+  <data name="WhereWithRelatedEntities1" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Extent1.Id, 
+Extent1.Name, 
+Extent1.MinAge, 
+Extent1.SupplierId
+FROM Toys AS Extent1 INNER JOIN Companies AS Extent2 ON Extent1.SupplierId = Extent2.Id
+ WHERE Extent2.State = @gp1</value>
+  </data>
+  <data name="WhereWithRelatedEntities2" xml:space="preserve">
+    <value>SELECT
+1 AS C1, 
+Filter1.Id, 
+Filter1.Name, 
+Filter1.MinAge, 
+Filter1.SupplierId
+FROM (SELECT
+Extent1.Id, 
+Extent1.SupplierId, 
+Extent1.Name, 
+Extent1.MinAge, 
+Extent2.Id AS Id1, 
+Extent2.Name AS Name1, 
+Extent2.DateBegan, 
+Extent2.NumEmployees, 
+Extent2.Address, 
+Extent2.City, 
+Extent2.State, 
+Extent2.ZipCode
+FROM Toys AS Extent1 LEFT OUTER JOIN Companies AS Extent2 ON Extent1.SupplierId = Extent2.Id
+ WHERE Extent2.State != @gp1) AS Filter1 LEFT OUTER JOIN Companies AS Extent3 ON Filter1.SupplierId = Extent3.Id
+ WHERE Extent3.State != @gp2</value>
+  </data>
+</root>
\ No newline at end of file

=== modified file 'MySql.Data.Entity/Tests/RelationalOperators.cs'
--- a/MySql.Data.Entity/Tests/RelationalOperators.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/RelationalOperators.cs	2011-03-03 18:01:04 +0000
@@ -29,25 +29,13 @@
 using System.Data.Common;
 using NUnit.Framework;
 using System.Data.Objects;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
 	[TestFixture]
 	public class RelationalOperators : BaseEdmTest
 	{
-        public RelationalOperators()
-            : base()
-        {
-        }
-
-        private EntityConnection GetEntityConnection()
-        {
-            string connectionString = String.Format(
-                "metadata=TestDB.csdl|TestDB.msl|TestDB.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
-            EntityConnection connection = new EntityConnection(connectionString);
-            return connection;
-        }
-
         [Test]
         public void Except()
         {
@@ -90,6 +78,10 @@
                 string entitySQL = @"(SELECT t.Id, t.Name FROM Toys AS t) 
                 UNION ALL (SELECT c.Id, c.Name FROM Companies AS c)";
                 ObjectQuery<DbDataRecord> query = context.CreateQuery<DbDataRecord>(entitySQL);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.UnionAll);
+
                 int i = 0;
                 foreach (DbDataRecord r in query)
                 {

=== modified file 'MySql.Data.Entity/Tests/RestrictionOperators.cs'
--- a/MySql.Data.Entity/Tests/RestrictionOperators.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/RestrictionOperators.cs	2011-03-03 18:01:04 +0000
@@ -30,29 +30,13 @@
 using NUnit.Framework;
 using System.Data.Objects;
 using System.Collections.Generic;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
-	/// <summary>
-	/// Summary description for BlobTests.
-	/// </summary>
     [TestFixture]
     public class RestrictionOperators : BaseEdmTest
     {
-        public RestrictionOperators()
-            : base()
-        {
-            csAdditions += ";logging=true;";
-        }
-
-        private EntityConnection GetEntityConnection()
-        {
-            string connectionString = String.Format(
-                "metadata=TestModel.csdl|TestModel.msl|TestModel.ssdl;provider=MySql.Data.MySqlClient; provider connection string=\"{0}\"", GetConnectionString(true));
-            EntityConnection connection = new EntityConnection(connectionString);
-            return connection;
-        }
-
         [Test]
         public void SimpleSelect()
         {
@@ -64,6 +48,9 @@
             using (testEntities context = new testEntities())
             {
                 var query = context.CreateQuery<Toy>("SELECT VALUE c FROM Toys AS c");
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SimpleSelect);
+
                 foreach (Toy t in query)
                 {
                     Assert.AreEqual(toys.Rows[i++]["name"], t.Name);
@@ -82,10 +69,11 @@
             using (testEntities context = new testEntities())
             {
                 var query = context.CreateQuery<Toy>("SELECT VALUE t FROM Toys AS t WHERE t.MinAge=4");
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SimpleSelectWithFilter);
+
                 foreach (Toy t in query)
-                {
                     Assert.AreEqual(toys.Rows[i++]["name"], t.Name);
-                }
             }
         }
 
@@ -101,6 +89,8 @@
             {
                 var query = context.CreateQuery<Toy>("SELECT VALUE t FROM Toys AS t WHERE t.MinAge>@age");
                 query.Parameters.Add(new ObjectParameter("age", 3));
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SimpleSelectWithParam);
 
                 foreach (Toy t in query)
                 {
@@ -118,8 +108,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE c FROM Companies AS c WHERE c.Address.City = 'Dallas'";
-                ObjectQuery<Company> query = context.CreateQuery<Company>(sql);
+                string eSql = "SELECT VALUE c FROM Companies AS c WHERE c.Address.City = 'Dallas'";
+                ObjectQuery<Company> query = context.CreateQuery<Company>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.WhereLiteralOnRelation);
 
                 int i = 0;
                 foreach (Company c in query)
@@ -136,8 +129,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = @"SELECT c.LastName FROM Employees AS c WHERE c.Age > 20";
-                ObjectQuery<DbDataRecord> query = context.CreateQuery<DbDataRecord>(sql);
+                string eSql = @"SELECT c.LastName FROM Employees AS c WHERE c.Age > 20";
+                ObjectQuery<DbDataRecord> query = context.CreateQuery<DbDataRecord>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.SelectWithComplexType);
 
                 int i = 0;
                 foreach (DbDataRecord s in query)
@@ -155,8 +151,11 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = "SELECT VALUE t FROM Toys AS t WHERE t.Supplier.Address.State = 'TX'";
-                ObjectQuery<Toy> query = context.CreateQuery<Toy>(sql);
+                string eSql = "SELECT VALUE t FROM Toys AS t WHERE t.Supplier.Address.State = 'TX'";
+                ObjectQuery<Toy> query = context.CreateQuery<Toy>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.WhereWithRelatedEntities1);
 
                 int i = 0;
                 foreach (Toy t in query)
@@ -177,9 +176,12 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = @"SELECT VALUE t FROM Toys AS t 
+                string eSql = @"SELECT VALUE t FROM Toys AS t 
                     WHERE t.Supplier.Address.State<>'TX' AND t.Supplier.Address.State <> 'AZ'";
-                ObjectQuery<Toy> query = context.CreateQuery<Toy>(sql);
+                ObjectQuery<Toy> query = context.CreateQuery<Toy>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.WhereWithRelatedEntities2);
 
                 int i = 0;
                 foreach (Toy t in query)
@@ -200,9 +202,12 @@
 
             using (testEntities context = new testEntities())
             {
-                string sql = @"SELECT VALUE c FROM Companies AS c WHERE EXISTS(
+                string eSql = @"SELECT VALUE c FROM Companies AS c WHERE EXISTS(
                     SELECT p FROM c.Toys AS p WHERE p.MinAge < 4)";
-                ObjectQuery<Company> query = context.CreateQuery<Company>(sql);
+                ObjectQuery<Company> query = context.CreateQuery<Company>(eSql);
+
+                string sql = query.ToTraceString();
+                CheckSql(sql, SQLSyntax.Exists);
 
                 int i = 0;
                 foreach(Company c in query)

=== modified file 'MySql.Data.Entity/Tests/SetOperators.cs'
--- a/MySql.Data.Entity/Tests/SetOperators.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Tests/SetOperators.cs	2011-03-03 18:01:04 +0000
@@ -30,17 +30,13 @@
 using NUnit.Framework;
 using System.Data.Objects;
 using System.Linq;
+using MySql.Data.Entity.Tests.Properties;
 
 namespace MySql.Data.Entity.Tests
 {
 	[TestFixture]
 	public class SetOperators : BaseEdmTest
 	{
-        public SetOperators()
-            : base()
-        {
-        }
-
         [Test]
         public void Any()
         {
@@ -54,7 +50,10 @@
             using (testEntities context = new testEntities())
             {
                 var authors = from a in context.Authors where !a.Books.Any() select a;
+
                 string sql = authors.ToTraceString();
+                CheckSql(sql, SQLSyntax.Any);
+                
                 foreach (Author a in authors)
                     Assert.AreEqual(dt.Rows[i++]["id"], a.Id);
             }
@@ -71,6 +70,7 @@
                 var q = from o in context.Orders 
                             select o;
                 Order order = q.First() as Order;
+
                 Assert.AreEqual(id, order.Id);
             }
         }

=== modified file 'MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs'
--- a/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs	2011-02-15 21:07:24 +0000
+++ b/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs	2011-03-03 18:02:14 +0000
@@ -763,6 +763,7 @@
             return new Regex(BlobAsUTF8ExcludePattern);
         }
 
+#if !CF
         public override bool ContainsKey(string keyword)
         {
             try
@@ -776,6 +777,7 @@
                 return false;
             }
         }
+#endif
 
         public override object this[string keyword]
         {

=== modified file 'MySql.Data/Tests/Source/CommandTests.cs'
--- a/MySql.Data/Tests/Source/CommandTests.cs	2011-02-14 17:19:36 +0000
+++ b/MySql.Data/Tests/Source/CommandTests.cs	2011-03-03 18:02:14 +0000
@@ -498,7 +498,7 @@
             try 
             {
                 cmd.ExecuteNonQuery();
-                Assert.Fail();
+                Assert.Fail("Should not get here");
             }
             catch (InvalidOperationException)
             {

=== modified file 'MySql.Data/Tests/Source/ConnectionStringBuilder.cs'
--- a/MySql.Data/Tests/Source/ConnectionStringBuilder.cs	2011-02-15 21:06:20 +0000
+++ b/MySql.Data/Tests/Source/ConnectionStringBuilder.cs	2011-03-03 18:01:04 +0000
@@ -117,6 +117,7 @@
             Assert.IsTrue(s.Pooling);
         }
 
+#if !CF
         /// <summary>
         /// Bug #59835	.Net Connector MySqlConnectionStringBuilder wrong result ContainsKey function
         /// </summary>
@@ -131,5 +132,6 @@
             Assert.IsTrue(s.ContainsKey("host"));
             Assert.IsFalse(s.ContainsKey("badkey"));
         }
+#endif
     }
 }

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into connector-net-trunk branch (reggie.burnett:967) Reggie Burnett3 Mar