I have an old project that was developed by the .Net framework and RavenDB 3 ... I'm trying to migrate the RavenDB to the 5.* version there is weird behavior in translate a Linq query to the RQL query
The below codes in c#
var query = documentSession
.Query<Documents_ByOrgan.Result, Documents_ByOrgan>()
.Where(x => x.OrganisationId == request.OrganisationId);
query = (from result in query
let onboarding = RavenQuery.Load<IOnboarding>(result.OnboardingDocumentId)
let onboradGroup = RavenQuery.Load<IGroup>(onboarding.Group.DocumentId)
let invitedBy = RavenQuery.Load<User>(onboarding.InvitedByUser.DocumentId)
let siteDoc = RavenQuery.Load<Site>(((Team)onboradGroup).Site.DocumentId)
select new
{
OnboardingId = onboarding.Id,
...
}).ProjectInto<T>();
Translates to the RQL in this way :
declare function output(result, onboarding) {
var onboradGroup = load(id(onboarding.Group));
var invitedBy = load(id(onboarding.InvitedByUser));
var siteDoc = load(onboradGroup.Site.DocumentId);
return { ... };
}
from index 'Onboardings/All' as result
result.OnboardingDocumentId as onboarding
select output(result, onboarding)
Why
let siteDoc = RavenQuery.Load<Site>(onboradGroup.Site.DocumentId)
translates to :
var siteDoc = load ( onboradGroup.Site.DocumentId );
BUT
RavenQuery.Load<IGroup>(onboarding.Group.DocumentId)
translates to the:
var onboradGroup = load ( id ( onboarding.Group ) );
how can I prevent from generating id(..) in RQL?
id(..) doesn't load any document
there is a lot of these queries in my project and all of them works fine with the 3.x version
In addition, I have the below config :
documentStore.Conventions.FindIdentityProperty = memberInfo => memberInfo.Name == "DocumentId";
there is a discussion here that helps me to find the problem