SubSonic Forums
All Your Database Are Belong To Us

ExecuteTypedList and Partial Classes

Latest post 08-25-2008 7:02 AM by jtodaa. 6 replies.
  • 08-10-2008 3:47 AM

    • jtodaa
    • Top 500 Contributor
    • Joined on 02-14-2008
    • Posts 5

    ExecuteTypedList and Partial Classes

    Trying out SubSonic 2.1 and ExecuteTypedList.  I've created a partial class Order to an already generated class by SubSonic called Order. My partial class has an OrderTotal member that's the total cost of the order.  When using a stored proc and calling  ExecuteTypedList<Order> my new member doesn't get populated.  Is this expected behavior? 

    If I define my own basic class OrderExtended with all the same members from both partial Order classes calling ExecuteTypedList<OrderExtended> fully populates all members (including the OrderTotal).

    Thanks

     

    Filed under:
  • 08-10-2008 5:57 AM In reply to

    Re: ExecuteTypedList and Partial Classes

     What does your OrderExtended.OrderTotal get populated with ?

    Since (in your partial class problem) you are adding OrderTotal as a member , it can't be an original member of Order.

    If it isn't a member of Order, ExecuteTypedList wont populate it with anything as it populates by matching member names.

    Scratch that, I just realized you are executing a stored procedure.

     

     

  • 08-12-2008 12:09 AM In reply to

    Re: ExecuteTypedList and Partial Classes

    What do you mean by OrderTotal doesn't get populated don't you do this on the fly?

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

  • 08-13-2008 8:21 PM In reply to

    • jtodaa
    • Top 500 Contributor
    • Joined on 02-14-2008
    • Posts 5

    Re: ExecuteTypedList and Partial Classes

    The stored procedure returns an OrderTotal column along with the other standard Order columns.  The OrderTotal is calculated on the fly in the stored proc.  I've then added my own partial Order class to the SubSonic generated class.

      public partial class Order

      {

        public decimal OrderTotal { get; set; }

      }

    When using the stored proc and ExecuteTypedList on the Order class only the SubSonic partial Order class members get populated. The OrderTotal member remains empty. But if I define a new class:

      public class OrderExtended

      {

        public int OrderID { get; set; }

        public string Address { get; set; }

        public string FullName { get; set; }

        public decimal OrderTotal { get; set; }

      }

    Everything gets populated using ExecuteTypedList<OrderExtended>.  So the question is when using ExecuteTypedList for stored procedures do you need to define a new class from scrath that contains all the members you want or are partial classes supported and I am simply doing something wrong?

    Filed under:
  • 08-13-2008 8:42 PM In reply to

    Re: ExecuteTypedList and Partial Classes

    I see what the problem is, it has nothing to do with partial's when you call ExecuteTypedList SubSonic checks to see if it inherits from one of its base classes as is the case with the generated code.

    If it inherits from a SubSonic base class then it goes thru the default way of populating the object using the Schema that is built into the generated object.

    But if it is a plain POCO object then it matches the names of the properties.

    So that why you are seeing that effect.

    What do you think is this is a bug?

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

  • 08-19-2008 7:24 AM In reply to

    • jtodaa
    • Top 500 Contributor
    • Joined on 02-14-2008
    • Posts 5

    Re: ExecuteTypedList and Partial Classes

    I would say so as I fully expected my partial class properties to get popualted. I guess it depends on whether this scenario was already considered. If so I'd assume there's a reason for not matching properties and using SubSonic's default way (ie performance).  At any rate it's worth finding out.  So is it best to submit an issue on codeplex or is there another way to confirm it's a bug before raising it there?

    Filed under: ,
  • 08-25-2008 7:02 AM In reply to

    • jtodaa
    • Top 500 Contributor
    • Joined on 02-14-2008
    • Posts 5

    Re: ExecuteTypedList and Partial Classes

    Raised an issue on codeplex.  We'll see what happens.

    http://www.codeplex.com/subsonic/WorkItem/View.aspx?WorkItemId=18074

     

    Filed under: ,
Page 1 of 1 (7 items) | RSS