0

I'm trying to do the same as this example does under title "Attribute-On-Relationship to Query other Fields". I'm editing Blog application visual query. So I have RelationshipFilter, which takes entities of type Category via Default in point. And I want to filter them by field Name. Here I can get list of names either from params or from list of posts and their categories. That's not a problem as far as I understand.

So looks like Name has to be of entity type. I'm struggling right now with this filter, since I want to filter Category by field Name of simple text type. Which means that I have nothing to specify in Relationship Attribute. EntityTitle or just empty Relationship Attribute field don't work and cause Bad Request error. So is there a way to make it work?

P.S. ValueFilter is not an option, since it doesn't support returning nothing if there are no items, that satisfy condition and also it supports only filter by item's Attribute, that contains Value and no option that Value can contain any in Attribute with separator.

1 Answers1

0

The RelationshipFilter is only meant for relationships (item with item) - and you seem to want to do a string-compare.

I'm not really sure what you should do because I don't have context, but if things get really special, best use LINQ instead. Check out the tutorials for LINQ here: https://2sxc.org/dnn-tutorials/en/razor/linq/home

iJungleBoy
  • 5,325
  • 1
  • 9
  • 21
  • Linq is applicable when you have data on the page already for code behind. I want to apply filter at database level. For instance, I want to get all posts that contain either "word" or "debug" in `Title` property. So I would specify "word,debug" in `Filter`, "Title" in `Relationship Field`, comma separator and operator `containsany`, but I don't need `Relationship Attribute` here since I need item itself, because item is string and doesn't have any attributes in visual queries as far as I understand. – Constantine Ketskalo Oct 21 '20 at 17:43
  • And ValueFilter is not an option, because, for instance, it doesn't allow to get a post with title "word and another one" from filter "word,debug". – Constantine Ketskalo Oct 21 '20 at 17:48
  • And with linq paging is not going to speed up work of website since every page is going to retrieve all posts in order to apply filtering and sorting. – Constantine Ketskalo Oct 21 '20 at 17:49
  • I'm very confused about what you're trying to do - basically I didn't understand the "word,debug" at all. Could you give a specific example? I'm pretty sure this should be easy to achieve - probably using 2-3 tokens. BTW: All 2sxc data is cache in-memory on the web-server. So VisualQuery and LINQ kind of do the same thing, just that visual query has additional optimizations and is easier to use for many scenarios. – iJungleBoy Oct 22 '20 at 06:05
  • By "word,debug" I mean that, for instance, I have query string parameter with value "word,debug". So its value is a list of words separated with comma. And lets say I need to get a list of posts, which contain any of these words in their title. For instance titles "word and another one" and "debug in process" both satisfy this condition. And after that I'd apply paging. Looks like pretty simple task, but I don't see its solution within current visual queries functionality. Looks like it has to be done in the code behind in razor pages. – Constantine Ketskalo Oct 22 '20 at 08:24
  • I believe you're right - I don't think we have a contains-clause as of now. – iJungleBoy Oct 23 '20 at 09:34
  • I hope you'll add it in future. I have just started working with 2sxc module recently and I already stumbled upon this scenario few times, where I needed contains-clause (or is contained or combo of both like "contains any in any of these", nor sure how to name it correctly). Thanks for your time anyway. – Constantine Ketskalo Oct 23 '20 at 11:40