开发者

How to Filter ADO.NET data using a Full Text Search (FTS) field?

开发者 https://www.devze.com 2022-12-17 15:04 出处:网络
We are using ADO.NET dataservices & are building URL based filters. Example: /Customers?filter=City eq \'London\'

We are using ADO.NET dataservices & are building URL based filters. Example: /Customers?filter=City eq 'London'

We now need to filter on 开发者_StackOverflow社区a Full Text 'tags' Field. WAS HOPING FOR: /Customers?filter=Tag like 'Friendly'

PROBLEM: ADO.NET does not have a LIKE operator. ADO.NET does not seem to like FTS (It is not finding a match - because it is not parsing through the CSV's)

Any ideas how to make this work? THX


ADO.NET Data Services do support "LIKE" kind of operator.

Queries like this:

http://localhost/EntitiesService.svc/CalEvents?$filter=indexof(Subject,'fO') ge 0

http://localhost/EntitiesService.svc/CalEvents?$filter=substringof('fox',Subject) eq true

or LINQ version:

 var result  = _context.CalEvents.Where(ce => ce.Subject.Contains(searchTerm))

Do probably what you looking for. They generate a SQL query with "LIKE" operator and add "%" to the search term. So, they act like "LIKE" operator.

FTS with "Contains" operator for example .. is not supported, I do not have time to check for sure but I think I saw it not so long ago.

More information: http://www.odata.org/developers/protocols/uri-conventions


I haven't worked with ADO.NET Data Services per se, but, when working with Full Text Search, I have found that the CONTAINS operator is much more powerful. Whether in an ad hoc sql string, or in a stored proc.

0

精彩评论

暂无评论...
验证码 换一张
取 消