C# Linq to Entities-查询以检查“上的匹配”;";输入的字符数

C# Linq to Entities-查询以检查“上的匹配”;";输入的字符数,c#,entity-framework,sql-server-2012,linq-to-entities,C#,Entity Framework,Sql Server 2012,Linq To Entities,我想根据用户键入的字符返回一组结果 我已经创建了以下查询,它在LINQpad4中实现了我想要的功能 LinqPad var PostCodes = (from OA in OrganisationAddresses join OV in OpportunityVersions on OA.ID equals OV.LocationID where OA.CurrentVersion.PostCode.Contains("LH")

我想根据用户键入的字符返回一组结果

我已经创建了以下查询,它在LINQpad4中实现了我想要的功能

LinqPad

var PostCodes = (from OA in OrganisationAddresses
               join OV in OpportunityVersions on OA.ID equals OV.LocationID
               where OA.CurrentVersion.PostCode.Contains("LH") 
               select OV.ID).ToList();

PostCodes.Dump();
用户输入字符串“LH”,我得到13个结果

现在,当我在我的生产环境中放置一个非常类似的查询时,如果我输入“LH”,我将得到零结果。它仅在输入完整字符串(如“LH1 1HP”)时返回匹配项

生产

Builder = Builder.And(o => 
(from OA in Context.OrganisationAddresses
 join OV in Context.OpportunityVersions on OA.ID equals OV.LocationID
 where Options.PostCode.Contains(OA.CurrentVersion.PostCode) 
 && OV.ID == o.CurrentVersionID select OV.ID).Any());
我正在使用SQLServer2012和LINQ访问实体。我想知道这可能是什么原因,以及如何修复它


谢谢

您似乎错误地交换了一些代码

Builder = Builder.And(o => 
(from OA in Context.OrganisationAddresses
 join OV in Context.OpportunityVersions on OA.ID equals OV.LocationID
 where OA.CurrentVersion.PostCode.Contains(Options.PostCode) // fix in this string
 && OV.ID == o.CurrentVersionID select OV.ID).Any());
在prod中还有其他条件:

&& OV.ID == o.CurrentVersionID

LinqPad查询与生产系统中的查询有何关联?他们看起来完全不同!啊,是的,我错了,我编辑了它。不过,在检查匿名类型时,需要条件的最后一部分