LinqKit Predicate Builder throws TypeLoadException?

丶灬走出姿态 提交于 2019-12-11 02:32:44

问题


I am experiencing a problem while attempting to execute a query that I have built dynamically using PredicateBuilder.

I am able to build the query but when executing the query itself I get the following "TypeLoadException"...

When running: return context.SearchRecords.AsExpandable().Where(predicate).ToList();

Could not load type 'System.Data.Entity.Infrastructure.IDbAsyncEnumerable`1' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

I have been pulling my hair out with this for quite a while now, I have checked online examples etc and I seem to be doing everything correctly so I would expect this to work.

private IEnumerable<SearchDto> BuildAndExecuteQuery(string queryString)
    {
        var queryWords = this.GetQueryWordsFromQueryString(queryString);
        using (var context = new AlleyOopSearchContext())
        {
            var predicate = PredicateBuilder.False<SearchDto>();
            foreach (var word in queryWords)
            {
                var temp = word;
                predicate = predicate.Or(p => p.ShotDescription.Contains(temp));
            }

            return context.SearchRecords.AsExpandable().Where(predicate).ToList();
        }
    }

Project is built using .NET Framework 4.5 and uses Entity Framework 6.

Thanks in advance!


回答1:


After more investigation I found the answer for myself, it turned out that anouther project within the solution was referencing a newer version of Entity Framework.

Upgrading all projects to the same version solved this issue.



来源:https://stackoverflow.com/questions/25723533/linqkit-predicate-builder-throws-typeloadexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!