Alternate Column Mapping?

26 views
Skip to first unread message

Matt Richard

unread,
Aug 28, 2014, 1:15:29 PM8/28/14
to simpl...@googlegroups.com
The column names in almost all of our (too old to change) databases, use a name prefix based on the table it's in (e.g. NpcId is the id column for the "NewsPostComment" table).   I don't want these ugly column names to "leak" into my C# code that deals with this database just so that I can directly "cast" simple records to my concrete type.  I looked at trying to add an extension point in Simple Data itself that would allow me to supply a custom column mapping, but I'd need to have some way to provide that mapping to PropertySetterBuilder which is somewhat a beast :).  Anyway the task looked really daunting so I started trying to come up with other solutions.  Here's my ideas:

1) Bite the bullet and figure out a reasonable way to do it through PropertySetterGetter
2) Use 2 sets of objects (e.g. NewsPostCommentDto and NewsPostComment) and use something like AutoMapper to translate between them within my data layer.
3) Don't use the mapping at all and create the objects myself.

What would you recommend  for dealing with this? 

Israel García

unread,
Dec 4, 2014, 5:11:03 PM12/4/14
to simpl...@googlegroups.com
I was looking into this feature as well, I have the same issue and I was thinking that a good feature could be to include a Mapper (table and column) as part of the implementation, by default a Mapper could be based on the db schema but giving the posibility to inject a new mapper according to our needs, for example I want to map table name: "Users" to the real DB table name: "NCL_Users". in order to avoid using those ugly names. 

Do you think that could be something that you can include as part of the project or do you suggest some way to achieve this?

Thank you.
Israel.
Reply all
Reply to author
Forward
0 new messages