我想要返回一组基于用户输入的字符的结果。
我创建了以下查询,它在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实体。我想知道是什么原因造成的,以及如何解决它。
谢谢
发布于 2017-01-11 11:28:53
你好像错误地交换了代码
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.CurrentVersionIDhttps://stackoverflow.com/questions/41589196
复制相似问题