Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:49:34+00:00 2026-05-26T08:49:34+00:00

I’m working on building a custom module in Orchard CMS, and I have the

  • 0

I’m working on building a custom module in Orchard CMS, and I have the following Controller Action:

public ActionResult Inventory()
{
   var models = _repository.Get<MyModel>();
   return View(new MyViewModel() { MyModels = models.ToList() });
}

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.

The exception is method get_Id should be ‘public/protected virtual’ or ‘protected internal virtual’.

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.

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.

EDIT: Additional Information

_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.

public interface IDbRepository : IDependency
{
    T Find<T>(long id) where T : class, IActiveRecord;
    bool Update<T>(T record) where T : class, IActiveRecord;
    bool Remove<T>(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; }
}

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:49:34+00:00Added an answer on May 26, 2026 at 8:49 am

    Orchard auto-mapping configuration assumes that any class will be mapped if the following conditions are met:

    • the namespace ends with “.Models” or “.Records”
    • there is an Id property, with virtual accessors
    • the class is neither sealed nor abstract
    • the class doesn’t implement IContent or inherits from ContentPartRecord

    So if you prevent any of those criteria from being true, you should be good. For instance, defining your classes in a namespace not ending with .Models or .Records should be sufficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.