Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : Bugs & Issues : Null reference to list in many to many relationship

Date Post
5/1/2008 2:48:35 PM

I have a many to many relationship created in my database with FK constraints to the related tables. I am trying to add to the list of objects for each item selected in a check box. See code below. I am getting a null object reference to the focus.TitleList and I don't understand why. I created a new instance to my focus object so that is not null, but why would the TitleList be null?

focus = new UnitVisitTracking.Business.Focus();

foreach (ListItem item in this.TitleList.Items)

{

if (item.Selected)

{

UnitVisitTracking.Business.Title newTitle = UnitVisitTracking.Business.Title.RetrieveByKey(Convert.ToInt32(item.Value));

if (newTitle != null)

{ focus.TitleList.Add(newTitle); }

}

}

5/1/2008 5:10:58 PM

How is focus.TitleList being initialized? You probably need to have the mapper create your focus object for you (using ObjectSpace<T>.Create()) so that the TitleList collection gets initialized.