Having The method or operation is not implemented when calling Count in IQueryable

4.8k Views Asked by At

I have a linq query using MySql Connector .NET v6.8.3 like this:

var query = from c in context.Containers
                            where c.isActive && !c.isDeleted
                            join pc in context.PublishedContainers on c.id_container equals pc.id_container
                            where pc.id_website == _siteId && pc.is_active && pc.is_visible && pc.is_revised == 9 //9 = revised
                            where pc.PublishedContainerProviders.Any()
                            where pc.PublishedContainerPresentations.Any(pcp => pcp.Presentation.PresentationServiceInfoes.SelectMany(psi => psi.PresentationServiceInfoLocations.Where(l => !string.IsNullOrEmpty(l.Location.googlemap))).Any())
                            select c;

and when i call query.Count() i'm getting The method or operation is not implemented exception and i dont know why..

What's going on?

Edit: If i call the ToList() method i have the same exception.

Edit 2: Exception:

`An error occurred while preparing the command definition. See the inner exception for details.`

StackTrace:

at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
   at System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
   at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator)
   at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at System.Linq.Queryable.Count[TSource](IQueryable`1 source)

Inner Exception: The method or operation is not implemented. StackTrace:

   at MySql.Data.Entity.SelectStatement.Accept(SqlFragmentVisitor visitor)
   at MySql.Data.Entity.ExistsFragment.Accept(SqlFragmentVisitor visitor)
   at MySql.Data.Entity.BinaryFragment.Accept(SqlFragmentVisitor visitor)
   at MySql.Data.Entity.SqlGenerator.FuseSelectWithInnerSelect(SelectStatement outer, SelectStatement inner)
   at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression)
   at MySql.Data.Entity.SqlGenerator.Visit(DbIsEmptyExpression expression)
   at MySql.Data.Entity.SqlGenerator.Visit(DbNotExpression expression)
   at MySql.Data.Entity.SqlGenerator.VisitBinaryExpression(DbExpression left, DbExpression right, String op)
   at MySql.Data.Entity.SelectGenerator.Visit(DbFilterExpression expression)
   at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.Visit(DbGroupByExpression expression)
   at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type)
   at MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression)
   at MySql.Data.Entity.SelectGenerator.GenerateSQL(DbCommandTree tree)
   at MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
   at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)

Edit 3: I just figured out that the problem is this line:

where pc.PublishedContainerPresentations.Any(pcp => pcp.Presentation.PresentationServiceInfoes.SelectMany(psi => psi.PresentationServiceInfoLocations.Where(l => !string.IsNullOrEmpty(l.Location.googlemap))).Any())
0

There are 0 best solutions below