我正在运行以下LINQ to sql查询但它没有返回结果.. 但是当我在sql server中运行它[等效]时它返回数据!!
select * from [LocalizedProperty]
where LanguageId = 3
and LocaleValue like '%cards%'
and (LocaleKey = 'Name' or LocaleKey = 'Description')
和linq查询
Dim suggesstions As IEnumerable(Of LocalizedProperty) = _
(From sugg In result
Where sugg.LanguageId = 3 _
AndAlso sugg.LocaleValue.Contains(catalogRetrieveInfo.search_term) _
AndAlso (sugg.LocaleKey = "Name" OrElse sugg.LocaleKey = "Description") Select sugg)
这是对的吗?
答案 0 :(得分:1)
我认为会是这样的。
from sugg In result Where sugg.LanguageId == 3 && sugg.LocaleValue.Contains(catalogRetrieveInfo.search_term) && sugg.LocaleKey == "Name" || sugg.LocaleKey == "Description" select sugg
您还可以使用LINQPad尝试测试查询。使用LINQPad,您可以将LINQ查询转换为SQL。
让我知道它对你有用。