Get Name of SimpleDb Domain from Class

Sep 22, 2010 at 4:36 PM

I'm trying to map the DomainName of a given model class. I figured Savant would already have a class that does this, and it appears to be:
Simple enough. But TypeItemMapping is marked as internal. Is there a prescribed way to do this? For now I've just switched the internal marker to public and disabled treating warnings as errors... . Love that about open source!

Sep 22, 2010 at 5:40 PM

Applications should only interact with the public abstract class ItemMapping, which is extended by the internal class TypeItemMapping.

TypeItemMapping is not part of the public API and may be restructured without regard to backwards compatibility or even removed completely. In fact, one of the items on my medium-term todo list is to remove TypeItemMapping.


Sep 22, 2010 at 5:45 PM
Edited Sep 22, 2010 at 5:45 PM

I should add there's a good chance things will break if you depend on TypeItemMapping even in the short term. There's another internal mapping class named ValuesItemMapping and most of the Savant code creates and uses instances of the latter class.

Sep 22, 2010 at 6:00 PM

OK. If it does happen to break, I'm happy to write a public, non-internal, non-abstract implementation.

I ran into a need for this when I tried to write a single generalized Controller that can scaffold any Model and handle storing to SimpleDB for any type. Any code that uses generalized select statements like this is going to need this feature from SimpleSavant, so such an implementation probably belongs in SimpleSavant eventually.

Sep 22, 2010 at 6:33 PM

Well, my main point is that the feature does already exist in the public API. Just read this doc page about Typeless operations for more details.

I know you started using Savant pretty early so this stuff may have been exposed in a later release than you're familiar with.



Sep 22, 2010 at 6:51 PM

Ah OK - so it's not abstract. I was able to do this with:

string simpleDbDomain = ItemMapping.Create(typeof(Model)).DomainName;

Sep 22, 2010 at 6:54 PM

ItemMapping is abstract. ItemMapping.Create() returns an instance of an internal concrete class that extends ItemMapping.

Glad that worked for you!