Note that there are some explanatory texts on larger screens.

plurals
  1. POOrchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties
    primarykey
    data
    text
    <p>I'm working on building a custom module in Orchard CMS, and I have the following Controller Action:</p> <pre><code>public ActionResult Inventory() { var models = _repository.Get&lt;MyModel&gt;(); return View(new MyViewModel() { MyModels = models.ToList() }); } </code></pre> <p>Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be.</p> <p>The exception is method get_Id should be 'public/protected virtual' or 'protected internal virtual'.</p> <p>I can add virtual to the properties, but I want to avoid having NHibernate have any part in looking at this object, it is unnecessary. </p> <p>My question is, how can I add a Model, access that model in a view and suppress Orchard from treating it as a PartRecord? I actually use the model in a separate repository, separate from the Orchard DB.</p> <p>EDIT: Additional Information</p> <p>_repository is an IDbRepository, pointing to my own DB instance MyModel is a POCO for my data. I'm trying avoid putting virtual on the properties in MyModel, I have them in here, to illustrate where I'm trying to avoid them.</p> <pre><code>public interface IDbRepository : IDependency { T Find&lt;T&gt;(long id) where T : class, IActiveRecord; bool Update&lt;T&gt;(T record) where T : class, IActiveRecord; bool Remove&lt;T&gt;(T record) where T : class, IActiveRecord; } public class MyModel : IActiveRecord { [Key] public virtual long Id { get; set; } public virtual int SupplierProductId { get; set; } public virtual int SupplierId { get; set; } public virtual int ProductId { get; set; } } </code></pre> <p>In addition to this, my module does have a settings part that I've created, that does get stored in Orchard DB and is edited in the site settings. I'm using a handler to control that. However, I've tried removing the handler and a few other things to keep Orchard from taking my object into NHibernate.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload