in

The ORM Foundation

Get the facts!

Handling uniqueidentifier

Last post 08-11-2009 16:26 by Matthew Curland. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-25-2009 17:30

    • nyxtom
    • Top 500 Contributor
      Male
    • Joined on 04-25-2008
    • Salt Lake City
    • Posts 1

    Handling uniqueidentifier

    What are the necessary steps needed to generate a uniqueidentifier for a primary key column at the ORM level. The data set type is not available, unless I'm missing something. Thanks :) Thomas
  • 06-26-2009 11:31 In reply to

    Re: Handling uniqueidentifier

    Hi Thomas,

    This has been a feature of all of Terry's ORM tools since InfoModeler was announced in the early 1990's. This is also the case with NORMA.

    With NORMA, the procedure for generating a relational model and then generating the DDL is explained in Tutorial 1 which you can download from the Library. A description of the relational procedure starts on slide 37 of the current version of Tutorial 1.  The data type of any ORM object can be seen (and edited) in the "Properties" window.

    If you already know this, then maybe I don't fully understand what's behind your question. Maybe you have tried to generate a table with a unique identifier and failed?

    Please note that within the next few hours I will be uploading updated versions of the existing NORMA tutorials plus two new tutorials.

    Ken 

  • 08-11-2009 12:54 In reply to

    • zzyxxs
    • Top 500 Contributor
      Male
    • Joined on 08-07-2009
    • Posts 1

    Re: Handling uniqueidentifier

    I have a similar question.  I'm trying to have the model generate a SQL Server DDL script where the data type of specified columns are 'uniqueidentifier' (corresponds to a GUID in C#).  On the properties tab of VS, I've tried Other: Object ID (doesn't generate a data type in the script) and Other: Row ID (generates an int identity).  Which Data Type option should I choose?  If one isn't available, is there something I can do with either the registry setting or one of the transforms?

  • 08-11-2009 16:26 In reply to

    Re: Handling uniqueidentifier

    The only solution I have for this right now is to highjack another data type and map it to what you need. To do this:

    1. Follow the instructions in http://www.ormfoundation.org/forums/p/593/1789.aspx#1789 except with the SQLServer transform file instead of the oracle transform. This should give you an alternate generator to transform DILtoSQLServer.
    2. Add the following lines somewhere in the body of your new transform.
    3. To get a generated uniqueidentifier data type, choose a Numeric: Decimal datatype and set the precision to 1000

     <xsl:template match="ddt:exactNumeric[@type='DECIMAL'][@precision=1000]" mode="ForDataTypeNumericPrecisionAndScale">
     </xsl:template>
     <xsl:template match="ddt:exactNumeric[@type='DECIMAL'][@precision=1000]">
      <xsl:text>uniqueidentifier</xsl:text>
     </xsl:template>

    Obviously, highjacking another datatype in the generator is a massive hack, but I'm not going to get to this in the immediate future. The issue isn't SQL server, it is dealing with the other DB targets that don't support this natively. AFAIK, uniqueidentifiers is not a SQL standard datatype.

    -Matt


     

Page 1 of 1 (4 items)
© 2008-2014 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service