I am creating an Orchard CMS module where I want to receive download data, but cannot decide how to do it.
For example, the Client has many events, so I have ClientRecord and EventRecord for them:
public class ClientRecord { private IList<EventRecord> _eventRecords; public virtual int Id { get; set; } public virtual string Company { get; set; } public virtual IList<EventRecord> EventRecords { get { return _eventRecords ?? (_eventRecords = new List<EventRecord>()); } set { _eventRecords = value; } } }
When I load a client into my ClientController
var clientRecord = _clientRepository.Get(id);
and then display "Events in my view"
<ul> @foreach (var eventRecord in Model.EventRecords) { <li> @eventRecord.Name (@eventRecord.StartDate.ToShortDateString()) </li> } </ul>
events are displayed, and MiniProfiler shows a separate request for lazy loading of events.
I tried to put the [Aggregate] attribute in the EventRecords collection in ClientRecord, but this had no effect.
I am not familiar with NHibernate, so hopefully this is something simple, but how can I tell if I want to load EventRecords when restoring ClientRecord?
[EDIT]
In Orchard CMS, NHibernate mappings are created for you based on the agreement that the class is called xxxRecord, and there is a database table with the same name.
So, you do not have (as far as I know) a mapping file in which you can specify this. If I am right about this, then the question is, is there a way to indicate whether you want to download the request that you use to retrieve the client (rather, like the Entity Framework), includes a "method".