Fluent API .Contains(variable)

Posted by Community Admin on 03-Aug-2018 17:57

Fluent API .Contains(variable)

All Replies

Posted by Community Admin on 24-Feb-2011 00:00

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".

Posted by Community Admin on 03-Mar-2011 00:00

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

Posted by Community Admin on 03-Mar-2011 00:00

Hi Radoslav,
 
Thank you for the reply.  Is there an estimate on the date when the OQL parser will be replaced?

Joe

Posted by Community Admin on 03-Mar-2011 00:00

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

Posted by Community Admin on 12-Apr-2011 00:00

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

Posted by Community Admin on 13-Apr-2011 00:00

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


This thread is closed