Awesome! Glad to help. :)

On Thu, Dec 10, 2009 at 12:37 PM, Chris Curvey <[email protected]> wrote:
> That would be it!  I knew it was something simple.
>
> On Thu, Dec 10, 2009 at 2:29 PM, Jonathan Vukovich <[email protected]>
> wrote:
>>
>> Shouldn't Foo IsValid() be virtual and Boo IsValid() be an override?
>> Just taking a quick shot at it.
>>
>>
>> On Thu, Dec 10, 2009 at 12:07 PM, Chris Curvey <[email protected]> wrote:
>> > I'm sure that I'm missing something basic, but I'm not sure if it's a
>> > C# thing that I'm missing, or an HQL thing that I'm missing, or an AR
>> > thing that I'm missing.  I hope someone can help.
>> >
>> > I have two classes in a single-table inheritance relationship
>> >
>> > [ActiveRecord("MyTable", DiscriminatorColumn="type",
>> > DiscriminatorType="string", DiscriminatorValue="Foo")]
>> > public class Foo : ActiveRecordBase<Foo>
>> > {
>> >   public bool IsValid() { ...do some stuff ...}
>> > }
>> >
>> > [ActiveRecord(DiscriminatorValue="Bar")]
>> > public class Bar : Foo
>> > {
>> >   public bool IsValid() { ... do some stuff ... }
>> > }
>> >
>> > So what I want to do is roll through a list of instances, and call
>> > IsValid() on each of them, taking advantage of polymorphism.  So I
>> > have this:
>> >
>> > SimpleQuery q = new SimpleQuery("from Foo where whatever ");
>> > Foo[] fooArray = q.Execute();
>> > foreach (Foo foo in fooArray)
>> > {
>> >    System.out.WriteLine(foo.IsValid())
>> > }
>> >
>> > But it always seems to call "Foo.IsValid()" and never calls
>> > "Bar.IsValid()".   Which kind of makes sense, as the "foo" variable
>> > has been declared as an instance of "Foo", but how do I set it up so
>> > that "foo.IsValid" calls the appropriate routine?  I've tried
>> > upcasting and downcasting, but I can't get it straight.
>> >
>> > So, what am I missing?
>> >
>> > --
>> >
>> > You received this message because you are subscribed to the Google
>> > Groups "Castle Project Users" group.
>> > To post to this group, send email to
>> > [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/castle-project-users?hl=en.
>> >
>> >
>> >
>
>
>
> --
> The source of your stress might be a moron
>

--

You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.


Reply via email to