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.