Base solution for your next web application
Open Closed

EF query bug #3718


User avatar
0
jaylan created

var countries = _blogRepository.GetAll().Include(c=> c.BlogPorts);

Problem: .Include(c=> c.BlogPorts) returning deleted (SoftDelete IsDeleted = 1) BlogPorts data also.

I use zero core 4.2


8 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    In Core version you need to manually handle soft delete filter on child entities. So what you have to do is filtering BlogPorts in where condition.

  • User Avatar
    0
    jaylan created

    Hi, I don't quite understand. Can you give me an example?

  • User Avatar
    0
    jaylan created

    <cite>alper: </cite> hi,

    In Core version you need to manually handle soft delete filter on child entities. So what you have to filter BlogPorts in a new where condition.

    Hi, alper

    I don't quite understand. Can you give me an example?

    thanks.

  • User Avatar
    0
    alper created
    Support Team

    var countries = _blogRepository.GetAll().Include(c=> c.BlogPorts.Where(p=> !p.IsDeleted));

  • User Avatar
    0
    jaylan created

    <cite>alper: </cite> var countries = _blogRepository.GetAll().Include(c=> c.BlogPorts.Where(p=> !p.IsDeleted));

    Hi, alper I have an exception.

    Mvc.ExceptionHandling.AbpExceptionFilter - The property expression 'e => {from BlogPortss in [e].BlogPorts where Not([p].IsDeleted) select [p]}' is not valid. The expression should represent a property access: 't => t.MyProperty'. For more information on including related data, see <a class="postlink" href="http://go.microsoft.com/fwlink/?LinkID=746393">http://go.microsoft.com/fwlink/?LinkID=746393</a>. System.InvalidOperationException: The property expression 'e => {from BlogPorts s in [e].BlogPorts where Not([p].IsDeleted) select [p]}' is not valid. The expression should represent a property access: 't => t.MyProperty'. For more information on including related data, see <a class="postlink" href="http://go.microsoft.com/fwlink/?LinkID=746393">http://go.microsoft.com/fwlink/?LinkID=746393</a>. 在 Microsoft.EntityFrameworkCore.Query.ResultOperators.Internal.IncludeExpressionNode.CreateResultOperator(ClauseGenerationContext clauseGenerationContext) 在 Remotion.Linq.Parsing.Structure.IntermediateModel.ResultOperatorExpressionNodeBase.ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext) 在 Remotion.Linq.Parsing.Structure.IntermediateModel.MethodCallExpressionNodeBase.Apply(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext) 在 Remotion.Linq.Parsing.Structure.QueryParser.ApplyAllNodes(IExpressionNode node, ClauseGenerationContext clauseGenerationContext) 在 Remotion.Linq.Parsing.Structure.QueryParser.ApplyAllNodes(IExpressionNode node, ClauseGenerationContext clauseGenerationContext) 在 Remotion.Linq.Parsing.Structure.QueryParser.GetParsedQuery(Expression expressionTreeRoot) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, ILogger logger, Type contextType) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_01.<CompileQuery>b__0() 在 Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func1 compiler) 在 Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult](Expression query) 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) 在 Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) 在 Remotion.Linq.QueryableBase1.GetEnumerator() 在 System.Collections.Generic.List1..ctor(IEnumerable1 collection) 在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Jaylan,

    For now, you can join _blogRepository.GetAll() and _blogPortsRepository.GetAll() using Linq query syntax. With EF Core 2.0, this problem will be solved I think.

    Thanks.

  • User Avatar
    0
    jaylan created

    <cite>ismcagdas: </cite> Hi @Jaylan,

    For now, you can join _blogRepository.GetAll() and _blogPortsRepository.GetAll() using Linq query syntax. With EF Core 2.0, this problem will be solved I think.

    Thanks.

    Thanks.

  • User Avatar
    0
    alper created
    Support Team

    thanks for your feedback