New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentQuery LINQ StartsWith issue #348

Closed
tusmester opened this Issue Apr 27, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@tusmester
Member

tusmester commented Apr 27, 2018

By @VargaJoe

var crmcontactsall = this.Model.Items.Where(c => c.Type("RorWebCRMContact") && c.Path.StartsWith(company.Path)).ToList();

This worked in 7.0.2, but after upgrading to 7.1.1 it gives 0 results without an error. If we replace the 'startswith' term with 'InTree' (which is the recommended way anyway) it works correctly.

var crmcontactsall = this.Model.Items.Where(c => c.Type("RorWebCRMContact") && c.InTree(company.Path)).ToList();

@kavics: Has something changed related to this feature in the last few releases? Should this work?
@VargaJoe: please clarify the type of Model.Items, is that a list in a collection view (ascx)?

@VargaJoe

This comment has been minimized.

Contributor

VargaJoe commented Apr 27, 2018

yes, the example code is from a ContentCollectionView

@kavics kavics self-assigned this Apr 27, 2018

kavics added a commit that referenced this issue May 2, 2018

@kavics

This comment has been minimized.

Contributor

kavics commented May 2, 2018

I cannot reproduce this bug so I would like to see/debug the actual solution. The ContentCollectionView.Model is a ContentCollectionViewModel (what a surprise). This object is generally an IQueryable that can wrap IEnumerable or ISnQueryable. This duality maybe can cause an error but I think this is not the case now.

@VargaJoe

This comment has been minimized.

Contributor

VargaJoe commented May 2, 2018

I've managed to reproduce the bug with the following steps:

  • installed services and webpages with snadmin
  • changed the contentcollectionview to insert a few extra rows
var test = this.Model.Items.Where(c => c.Type("Page") && c.Path.StartsWith("/Root/Sites/Default_Site")).ToList();
var test2 = this.Model.Items.Where(c => c.Type("Page") && c.InTree("/Root/Sites/Default_Site")).ToList();

and duplicate the foreach to use these lists

  • created a page with a ContentCollectionportlet and set to query all the page with CurrentSite bindings and use the modified view
    (interestingly, when I set CustomRoot with /Root or /Root/Sites, the portlet does not give results, but with CustomRoot /Root/Sites/Default_Site does)

  • on the test page the first foreach shows nothing and the second shows the two pages (login and the test page)

  • some extra test

var test3 = SenseNet.ContentRepository.Content.All.Where(c => c.Type("Page") && c.Path.StartsWith("/Root/Sites/Default_Site")).ToList();
var test4 = SenseNet.ContentRepository.Content.All.Where(c => c.Type("Page") && c.InTree("/Root/Sites/Default_Site")).ToList();

With the same result (test3 nothing, test4 working).

I could try to reproduce this on a demo site if there is any.

Components:
SenseNet.Services | 7.1.1 | 7.1.1 | sensenet Services
SenseNet.WebPages | 7.1.0 | 7.1.0 | sensenet ECM WebPages

Installed Packages:
1 | SenseNet.Services | sensenet Services | Install | 04/02/2018 | 05/02/2018 | 0 | 7.1.1 |   |  
2 | SenseNet.WebPages | sensenet ECM WebPages | Install | 04/05/2017 | 05/02/2018 | 0 | 7.1.0 |   |  

@kavics kavics added this to the Sprint 157 milestone May 2, 2018

@tusmester tusmester modified the milestones: Sprint 157, Sprint 158 May 2, 2018

tusmester added a commit that referenced this issue May 2, 2018

Fix/linq first (#346)
* Count experiment in ContentSet.
* SnLinq fixed and tested: First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault.
* Linq: ElementAt implemented.
* Linq LongCount, Any.
* Linq tests: AsQueryable, ThenByDescending
* Linq not supported methods: Select, Min, Max, Sum, Average, Aggregate.
* More not supported methods: Cast, Distinct, Concat, Union, Intersect, Except.
* SnLinq does not support: GroupJoin, GroupBy, All, SequenceEqual, Contains, DefaultIfEmpty, Reverse
* Linq does not support: Zip.
* Fix failed tests.
* Add a bug reproduction test.
* Change signature of a test extension method.
* Bug reproduction test (#348).
* Change warning suppress comments to an attribute on the Execute method of the ContentSet class.
* Fix: remove unnecessary methods.

@tusmester tusmester closed this May 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment