问题
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