我有一个使用MySql Connector .NET v6.8.3的linq查询,如下所示:
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;
当我致电query.Count()
时,我的The method or operation is not implemented
异常,我不知道为什么......
发生了什么事?
修改:
如果我调用ToList()
方法,我有相同的例外。
编辑2 : 例外:
`An error occurred while preparing the command definition. See the inner exception for details.`
堆栈跟踪:
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)
内部异常:The method or operation is not implemented.
堆栈跟踪:
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)
编辑3: 我只是发现问题就在这一行:
where pc.PublishedContainerPresentations.Any(pcp => pcp.Presentation.PresentationServiceInfoes.SelectMany(psi => psi.PresentationServiceInfoLocations.Where(l => !string.IsNullOrEmpty(l.Location.googlemap))).Any())