Understanding data joins and relationships in Orchard

In Orchard, how can a module developer know how a “connection” works, especially when connecting to main parts and recordings? One of the best tips I've seen was in the Orchard documentation , but none of these examples show how to build relationships with existing or core parts. As an example of something I'm looking for, here is a snippet of module service code taken from a working example:

_contentManager
    .Query<TaxonomyPart>()
    .Join<RoutePartRecord>()
    .Where(r => r.Title == name)
    .List()

In this case, the user TaxonomyPartconnects to the kernel RoutePartRecord. I examined the code, and I don’t see how Thaksinonmpart “connects” to RoutePartRecord. Similarly, from the working code here is another fragment driver code that associates a custom tag meter with the CommonPartRecord core:

List<string> tags = new List<string> { "hello", "there" };
IContentQuery<TagsPart, TagsPartRecord> query = _cms.Query<TagsPart, TagsPartRecord>();
query.Where(tpr => tpr.Tags.Any(t => tags.Contains(t.TagRecord.TagName)));
IEnumerable<TagsPart> parts =
    query.Join<CommonPartRecord>()
    .Where(cpr => cpr.Id != currentItemId)
    .OrderByDescending(cpr => cpr.PublishedUtc)
    .Slice(part.MaxItems);

It seemed to me that I could learn from any of the previous examples of how to form my own request. I have done this:

List<string> tags = new List<string> { "hello", "there" };
IContentQuery<TagsPart, TagsPartRecord> query = _cms.Query<TagsPart, TagsPartRecord>();
query.Where(tpr => tpr.Tags.Any(t => tags.Contains(t.TagRecord.TagName)));
var stuff =
    query.Join<ContainerPartRecord>()
    .Where(ctrPartRecord => ctrPartRecord.ContentItemRecord.ContentType.Name == "Primary")
    .List();

The purpose of my code is to limit the found content elements to only those that are in a specific container (or blog). When the code was run, it threw an exception from my connection request, saying {"could not resolve property: ContentType of: Orchard.Core.Containers.Models.ContainerPartRecord"}. This leads to many questions:

  • Display() - CommonPartRecord, ContainerPartRecord? , , , ?
  • , , / ( )? , models Part CommonPartRecord. , , - , -, ?
  • , TagsPart ContainerPartRecord ? ?
  • Orchard, NHibernate LINQ to NHibernate? NHibernate, NHibernate , Orchard?

, , - . , Orchard.

+5
1
  • , , . , . , 1.x, 1.3.
  • , . : .
  • . , , , .
  • - Orchard Content Manager, , , , . , HQL, 1.x .

, , , . , , . - . , , . , .

+3

All Articles