views:

412

answers:

1

Hi guys,

This may seem like a simple question however i've spent the last hour trying to solve this.

I want to create a custom subsonic collection so that i can fill it with data from a query with multiple joins using the .ExecuteAsCollection<>(); method.

i've created the custom class and a custom collection and even a controller with the load method but i keep getting a null refernce exception from the ExecuteAsCollection<>();

the stack track says its an error coming from the SubSonic.Load method.

i have left out the class's "SQLProps" that all the other subsonic classes have, but i was hoping i wouldn't have to go through each field painstakingly.

There has to be something simple i'm missing. Can someone who's done this give me a quick run down on what is required by subsonic to fill a custom collection with a query?

thanks Doug

UPDATE:

i forgot to mention that i also added the public Columns struct with all my columns.

+1  A: 

ExecuteAsCollection<T>() will only work with SubSonic-generated collections. You can map the result of a query to an arbitrary object type with ExecuteTypedList<T>(). This will match the columns returned from your query to properties of type T with the same name and give you List<T>.

John Sheehan
thanks champ... i'll give that a try - do the properties of the list item type have to match the subsonic field names (ie Pascal cased/pluralised) or do they need to match you database fields (which might not be pluralised)
Doug
only the spelling - not the casing.
Rob Conery