OK, then I suppose ignore the abstract requirement (just trying to maintain
best practices in the code. wouldn't want a dev trying to new up a base
class which can't live on its own..)

assuming a basic inheritance example:

domain:

public class EntityBase
{
    public virtual string ID {get;set;}
    public virtual DateTime CreateDate {get;set;}

    public virtual string Type {get;}
    public virtual string SubTypeType {get;} // was abstract to force
override in children..
    ...
}
public class EntityChildA : EntityBase
{
    public string ACustomProperty {get;set;}
    public override string SubTypeType {get {return "ECA";} }
}
 public class EntityChildB : EntityBase
{
    public string BCustomProperty {get;set;}
    public override string SubTypeType {get {return "ECB";} }
}


table (1):

|   ID     |   SubTypeType   |   CreateDate   |   ACustomProperty   |
BCustomProperty   |



----------------------------------------------------------------------------------------------

now, as for explaining my original question of crazy schema ...

there are other existing tables which are also the same 'type' as these
entities.
(This is why it's SubTypeType above..)

perhaps trying to map this schema is not something i should try to do, and
interface the 1,2,3 types to perform common actions across them.

But that means I still need to know how to map the first, 'easy', scenario.

so the thinking would be:

tables (3, in this ex) might look like:

 |   ID     |   Type   |   SubTypeType   |   CreateDate   |   1AProperty
|
|   ID     |   Type   |   SubTypeType   |   CreateDate   |   2AProperty   |
 |   ID     |   Type   |   SubTypeType   |   CreateDate   |
3ACustomProperty   |    3BCustomProperty   |

which might represent 4 (child) types:

 public class EntityBase
{
    public virtual string ID {get;set;}
    public virtual DateTime CreateDate {get;set;}

    public virtual string Type {get;}
    public virtual string SubTypeType {get;} // was abstract to force
override in children..
    ...
}public class EntityChild1A : EntityBase
 {
    public string 1AProperty {get;set;}
    public override string Type {get {return "1A";} }
    public override string SubTypeType {get {return "A";} }
}
public class EntityChild2A : EntityBase
{
    public string 2AProperty {get;set;}
    public override string Type {get {return "2A";} }
    public override string SubTypeType {get {return "A";} }
}
public class EntityChild3A : EntityBase
{
    public string 3ACustomProperty {get;set;}
     public override string Type {get {return "3A";} }
    public override string SubTypeType {get {return "A";} }
}
public class EntityChild3B : EntityBase
{
    public string 3BCustomProperty {get;set;}
    public override string Type {get {return "3B";} }
    public override string SubTypeType {get {return "B";} }
}

Thanks =)

------
Joe Brockhaus
[email protected]
------

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.

Reply via email to