StrataFrame Forum

SQL Server Column Names

http://forum.strataframe.net/Topic24549.aspx

By Tim Dol - 9/5/2009

I am trying to build business objects for a thirdy party database where some of the column names contain a 'space' or a 'hyphen'.



Example: 'E-MailID' or 'Field Name'



The mapper has no problem building the partial class for these fields but I guess these names are invalid in VB.



Any suggestions on how to get around these issues and still be able to manage the database. I can't change the field names - it's not my database.



Thanks,

Tim
By Peter Jones - 9/5/2009

Hi Tim,



You could try changing the designer code to enclose them in square brackets, e.g. [Field Name]



Cheers, Peter
By Trent L. Taylor - 9/7/2009

Actually this will most likely not work due to the compiler nature of .NET.  This violates basic compiler rules. 

In this case you may be required to create a custom property without the hyphen or space and then pull that value out of the data table.  The data table should hold the original column name since it is weak typed.

By Greg McGuffey - 9/8/2009

The square bracket thing isn't going to work (just tried it..boom). The issue with the custom properties is that the BO mapper will still map it incorrectly and anything I can think of fix that (like mapping to a dummy table) would break updates/inserts/deletes. I guess you could NOT map it and custom write what you need (i.e. all the custom properties, figure out what in the designer file you'd need to replicate)...but that seem like a huge pain.



If you have access to the database (i.e. you can add some other objects to it), you might consider a few things:



- Dummy tables that you map against and then sprocs for inserts/updates/deletes.



- You might have a "front-end" table that has an INSTEAD OF trigger, which in turn updates the actual table.



- An updatable view that you'd map against and then would allow updates/inserts/deletes.



Just throwing out some ideas. Not sure any fit your needs.
By Tim Dol - 9/9/2009

Thanks guys, I went with the option of creating the structure in the toolkit and then using a SP to extract the data using Aliases for the problem fields. Worked Perfectly.



Thanks,

Tim
By Trent L. Taylor - 9/9/2009

Cool Cool