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 7949339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:58:09+00:00 2026-06-04T01:58:09+00:00

Say I have the following AR Object: namespace Models { [ActiveRecord(Lazy = true, Table

  • 0

Say I have the following AR Object:

namespace Models
{
    [ActiveRecord(Lazy = true, Table = "Answer"), Serializable]
    public class Answer : ActiveRecordLinqBase<Answer>
    {
        public Answer() {}

        [PrimaryKey]
        public virtual int ID { get; set; }

        [BelongsTo("QuestionID")]
        public virtual Question Question { get; set; }
    }
}

Is there any way for me to directly set QuestionID? I tried creating an additional AR [Property] called QuestionID for this purpose, but I run into the NH error described here:

http://devlicio.us/blogs/derik_whittaker/archive/2009/03/19/nhibernate-and-invalid-index-n-for-this-sqlparametercollection-with-count-n-error.aspx

I am trying to unit test this class, and I really don’t want to have to set up a database (in memory or otherwise) to do this unit testing. Setting the QuestionID is all I need to do for the functionality currently under test.

Thanks.

  • 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-06-04T01:58:11+00:00Added an answer on June 4, 2026 at 1:58 am

    I found a hack that accomplishes what I need, but negatively impacts the NH cache (I think): I simply assign to a “new” Question, instantiated with the existing question’s ID. It looks horrible, and, like I said, it essentially loads the cache with these (very) partially-filled question objects (not verified, but behavior seems to indicate as much).

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

Sidebar

Related Questions

Say you have the following object: public class Address { public String Line1 {
Let's say I have the following class: public class Test<E> { public boolean sameClassAs(Object
Say I have the following: namespace SomeProject { public interface ISomething { string SomeMethod();
Let's say I have the following code static class ... { static object myobj
Say i have the following: public class Person{ public int ID {get; set;} public
Let's say I have the following command object: class BreakfastSelectCommand{ List<Breakfast> possibleBreakfasts; Breakfast selectedBreakfast;
Let's say I have following ORM classes (fields removed to simplify): class Animal(models.Model): say
Say I have the following: class C { private $f; public function __construct($f) {
ok say i have the following model: public class bar{ public string bar {get;
Let's say I have the following class class Parent(object): Options = { 'option1': 'value1',

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.