1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Fluent API .Contains(variable)

Fluent API .Contains(variable)

6 posts, 0 answered
  1. Joe
    Joe avatar
    3 posts
    Registered:
    21 Oct 2010
    24 Feb 2011
    Link to this post
    When using the Fluent API if I hard code a value in a .Contains (.Contains("x")) then I get results.  If I use a variable I always get an empty result set (.Contains(strSearchString)).

    Example:
            public IQueryable<ContentItem> GetGenericContent(string strTag, string strSearch)
            {
                var taxManager = TaxonomyManager.GetManager();
                var taxon = taxManager.GetTaxa<FlatTaxon>().Where(t => t.Name == strTag).Single();
                Guid guidid = taxon.Id;

                ContentManager manager = ContentManager.GetManager();

                IQueryable<ContentItem> contentItem = manager.GetContent()
                    .Where(t => t.Content.Contains(strSearch))
                    .Where(t => ((IList<Guid>)t.GetValue("Tags")).Contains(guidid))
                    .Where(t => t.Status == ContentLifecycleStatus.Live);

                return contentItem;
            }

    the same code will work if I switch the line containing the .Contains(strSearch) to .
    Where(t => t.Content.Contains("e"))
    it will pick up all content items that contain an "e".

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Mar 2011
    Link to this post
    Hi Joe,

    Thank you for using our service.

    This is an issue with the built in Sitefinity OQL parser which cannot translate the lambda expression to the proper SQL statement so that it filters for the search text. We are currently in the process decommissioning the OQL parser and substituting it with the Telerik OpenAccess built in OQL parser which has better support for lambda expressions.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
  3. Joe
    Joe avatar
    3 posts
    Registered:
    21 Oct 2010
    03 Mar 2011
    Link to this post
    Hi Radoslav,
     
    Thank you for the reply.  Is there an estimate on the date when the OQL parser will be replaced?

    Joe
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Mar 2011
    Link to this post
    Hello Joe,

    We are trying to push this migration for the 2011 Q1 release. Unless something critical pops up the OQL parser should be substituted within a month.

    Greetings,
    Radoslav Georgiev
    the Telerik team
  5. Blake
    Blake avatar
    10 posts
    Registered:
    28 Jul 2009
    12 Apr 2011
    Link to this post
    Hey Sitefinity,

    This issue is still present in
    Sitefinity 4.0.1210.0 SE

    I am trying to do a Fluent API query using Contains and it's not working.

    Here is my code:

    string text;

                List<Image> imageList = App.WorkWith().Images().Where(
                    i => i.Album.Title == MainLibraryName && i.Title.Contains(text)).Get().ToList();

    This doesn't work.  How can I get around this?

    Thanks!

    Blake
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Apr 2011
    Link to this post
    Hello Blake,

    Sitefinity 4.1 (which will contain the Lamba expressions fix) will be released later today. The Sitefinity 4.0 SP1 release does not contain the fix.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

6 posts, 0 answered