public virtual void Throws_when_orderby_multiple()
 {
     using (var context = CreateContext())
     {
         Assert.Equal(RelationalStrings.ClientEvalDisabled("orderby [c].IsLondon asc, ClientMethod([c]) asc"),
                      Assert.Throws <InvalidOperationException>(
                          () => context.Customers
                          .OrderBy(c => c.IsLondon)
                          .ThenBy(c => ClientMethod(c))
                          .ToList()).Message);
     }
 }
 public virtual void Throws_when_where_subquery_correlated()
 {
     using (var context = CreateContext())
     {
         Assert.Equal(RelationalStrings.ClientEvalDisabled(
                          "{from Customer c2 in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.Northwind.Customer]) where (([c1].CustomerID == [c2].CustomerID) AndAlso [c2].IsLondon) select [c2] => Any()}"),
                      Assert.Throws <InvalidOperationException>(
                          () => context.Customers
                          .Where(c1 => context.Customers
                                 .Any(c2 => c1.CustomerID == c2.CustomerID && c2.IsLondon))
                          .ToList()).Message);
     }
 }
 public virtual void Throws_when_group_join()
 {
     using (var context = CreateContext())
     {
         Assert.Equal(RelationalStrings.ClientEvalDisabled("join Int32 i in __p_0 on [e1].EmployeeID equals [i]"),
                      Assert.Throws <InvalidOperationException>(
                          () =>
                          (from e1 in context.Employees
                           join i in new[] { 1, 2, 3 } on e1.EmployeeID equals i into g
                           select e1)
                          .ToList()).Message);
     }
 }
 public virtual void Throws_when_select_many()
 {
     using (var context = CreateContext())
     {
         Assert.Equal(RelationalStrings.ClientEvalDisabled("from Int32 i in value(System.Int32[])"),
                      Assert.Throws <InvalidOperationException>(
                          () =>
                          (from c1 in context.Customers
                           from i in new[] { 1, 2, 3 }
                           select c1)
                          .ToList()).Message);
     }
 }
 public virtual void Throws_when_subquery_main_from_clause()
 {
     using (var context = CreateContext())
     {
         Assert.Equal(RelationalStrings.ClientEvalDisabled("[c].IsLondon"),
                      Assert.Throws <InvalidOperationException>(
                          () =>
                          (from c1 in context.Customers
                           .Where(c => c.IsLondon)
                           .Take(5)
                           select c1)
                          .ToList()).Message);
     }
 }
Exemplo n.º 6
0
        protected virtual void CheckClientEval([NotNull] object expression)
        {
            Check.NotNull(expression, nameof(expression));

            var relationalOptionsExtension = RelationalOptionsExtension.Extract(ContextOptions);

            switch (relationalOptionsExtension.QueryClientEvaluationBehavior)
            {
            case QueryClientEvaluationBehavior.Throw:
                throw new InvalidOperationException(RelationalStrings.ClientEvalDisabled(expression));

            case QueryClientEvaluationBehavior.Warn:
                QueryCompilationContext.Logger.LogWarning(RelationalStrings.ClientEvalWarning(expression));
                break;
            }
        }