I have such base type:

[HierarchyRoot(InheritanceSchema = InheritanceSchema.SingleTable)]
public abstract class FileSystemEntity: EntityBase
{
    [Field]
    [Association(OnOwnerRemove = OnRemoveAction.Cascade)]
    [FieldMapping("Childs")]
    public EntitySet<FileSystemEntity> Childs { get; set; }
    ...
}

and then have descendant type:

[TableMapping("tReleaseSnapshot_Files")]
public class ReleaseSnapshotFile : FileSystemEntity
{...}

But when domain is built, table for type ReleaseSnapshotFile is named FileSystemEntity and not tReleaseSnapshot_Files like i marked with attribute TableMapping. Is this expected behavior?

Update: Also i found that if attribute TableMapping is moved to parent type FileSystemEntity, then table is named right (tReleaseSnapshot_Files) but relation association defined by property Childs has table named FileSystemEntity-Childs-FileSystemEntity - it should be name like tReleaseSnapshot_Files_Childs_tReleaseSnapshot_Files or something similar, no?

asked Sep 14 '10 at 09:01

Peter%20%C5%A0ulek's gravatar image

Peter Ĺ ulek
492313236

edited Sep 14 '10 at 09:11


One Answer:

InheritanceSchema.SingleTable mode embodies that all types within an hierarchy are mapped to a single table, so TableMapping attribute should be applied to the root of the hierarchy, not to any of its children.

As for the second part of the post, it seems that the reported behavior is incorrect and must be fixed. I've opened an issue.

answered Sep 14 '10 at 10:09

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

I'd add it is incorrect even in the first case: why [TableMapping] makes any effect at all here?

And about auxiliary table name mapping: issue 250.

(Sep 14 '10 at 13:36) Alex Yakunin Alex%20Yakunin's gravatar image

TableMapping attribute makes possible to map the entire hierarchy to an arbitrary table (to a table with an arbitrary name). What's wrong in this scenario?

(Sep 14 '10 at 14:07) Dmitri Maximov Dmitri%20Maximov's gravatar image

He was applying [TableMapping] to non-[HierarchyRoot] type, although InheritanceSchema = InheritanceSchema.SingleTable.

IMO, [TableMapping] applied to a descendant of hierarchy root type is meaningless in this case, or even must be denied.

What is expected to be, if we'll apply different [TableMapping] to two different descendants of hierarchy root type in this case?

(Sep 14 '10 at 14:19) Alex Yakunin Alex%20Yakunin's gravatar image

IMO, [TableMapping] applied to a descendant of hierarchy root type is meaningless in this case, or even must be denied.

That's exactly what I'm talking about. Alex, plz, look at my first reply. May be I've misunderstood you comment, so forgive me for that mistake...

(Sep 14 '10 at 14:41) Dmitri Maximov Dmitri%20Maximov's gravatar image

Well, you wrote "... that must be fixed. I've opened an issue.", but it doesn't touch this problem at all - that's why I wrote ;)

I.e. there should be one more issue.

(Sep 14 '10 at 15:15) Alex Yakunin Alex%20Yakunin's gravatar image

Yes, you are right. Thanks for you advertence.

(Sep 15 '10 at 01:14) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×574
×23
×5

Asked: Sep 14 '10 at 09:01

Seen: 3,687 times

Last updated: Sep 15 '10 at 01:14

powered by OSQA