Function mapping with inherited types
Is there an example somewhere of doing functino mappings on inherited types?
I have gone down three roads and am not having any success with any of my ideas of how this might need to work.
I understand that if the derived type has function mappings then the base type must also.
But what do these sprocs look like?
I have tried various sets.
Thanks for any pointers.
I assume its possible since even the errors indicate that it is.
All Replies
- I'm not entirely sure what you're asking, but I'll take a stab at it.
The base type doesn't require function mappings if it's abstract. If it's not abstract, you could map it to a sproc that inserts nulls for all of the columns on the subtypes, and only takes parameters for the properties the base type defines.
If your sproc takes parameters for every column in the table, you could map only the columns included in the base type. To map that same sproc to the subtypes,you might want to try Colin Meek's suggestion in this post. Be aware that the added "wrapper" functions in the SSDL will be deleted by the Update Model from Database dialog if you use it. Another way to do it is to actually create different stored procedures in the database for each subtype.
Hope this helps,
Ryan Thanks for the pointer to the other blog post. I didn't use the magic search terms to find that one.
Definitely (and painfully) aware of the UpdateModel overwriting SSDL mods - but it is always good to point that out, just in case! I actually ahve a little text file with SSDL inserts that I have to reapply any time I do an update.
My real hope was to find an example. I spent way too many hours trying to come up with my own (based on what I already know about function mapping as well as TPT inheritance in EF) only to realize - okay, that idea didnt' pan out...nope, that one didn't either.
THe base type in this case is not abstract. While I agree that going COlin's route is an option, I still want to see HOW to make this work using the designer even if it means creating useless stored procedures in the database.
I literally want to see how to implement the different options even if they totally suck.
Julie,
Can you be more specific about what you've tried that hasn't worked? Creating a C/U/D sproc for each type in the hierarchy would be the simplest "brute force" approach and should work. I'll play with this with the latest bits and see if we're doing anything to block this scenario.
Noam
- I've written up a blog post about it, since it's too long to post here. It details one way of doing it using Colin Meek's idea.


