views:

78

answers:

0

Hi,

I've been working with subsonic for a few weeks now, and it is working really well. However, I've just run into an issue with child objects with additional partial properties. Some of it is probably me just not understanding the .Net object lifecycle.

I have an object - search. This has a few properties like permissions and stuff, and it links to a child table called search_options.

In my Asp.Net app, it loops through these search options and creates controls. Then on postback, it grabs the values and assigns it back to a "value" property on the search_option. This value property is a simple string that's defined in a partial class.

I then want to create a method on the search object, called PerformSearch. This then loops through the child search_options, and performs a custom query based on the "value" property.

However, even though I assign the "value" property to the child search_option, when I access it later via the search.search_options collection, it is null.

I'm guessing that maybe because it's accessing it in two different places, it performs another lazy load from the DB and the value is lost? Is there a way to tell the class that it's already loaded or something? or a way to access it so it's not reloaded from the DB?

Code is below (shitty pseudocode, not full version) :

ASP.Net page, loading back the values from postback :

dim obj_search as search = new subsonic.query.select().......' retrieves the search object

for each opt as search_option in obj_search.search_options
      opt.Value = Ctype(FindControl("search_option_" + opt.search_option_id),Textbox).Text

       debug.print(opt.Value) ' value is correct
next

for each opt as search_option in obj_search.search_options
      debug.print(opt.Value) 'this is nothing
next

Now, the partial class :

public partial class search_option

     private m_value as string
     public property Value() as string
            get
                return m_value
            end get
            set( byval value as string)
                 m_value = value
             end set
     end property
 end class