If possible, please provide an example where an insert statement returns the new key.

 

Page 3 and 4 of the “Data Mapper Developer Guide” has some rudimentary info but I have not been able to get it to work.

 

I need to modify the .NET Tutorial Web App to support auto-key generation when I insert a new person record.

 

This is what I have but is not working.

Please advise.

 

 

PersonHelp.cs

 

  public int Insert (Person person)

  {

    int mykey = Mapper ().Insert ("Insert", person);

 

    // Insert is designed so that it can return the new key

    // but we are not utilizing that feature here

 

    return mykey;

  }

 

 

PersonHelper.xml

 

  <insert id="Insert" parameterClass="Person">

    insert into PERSON

      (PER_FIRST_NAME, PER_LAST_NAME, PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M)

    values

      (#FirstName#, #LastName#, #BirthDate#, #WeightInKilograms#, #HeightInMeters#)

 

    <selectKey resultClass="int" keyProperty="id" >

      SELECT @@IDENTITY AS PER_ID

    </selectKey>

  </insert>

 

 

 

 


Gary P. Russo
Wolters Kluwer - Corporate Legal Services
111 Eighth Avenue
New York, NY 10011

Office: 212.590.9213
Cell:  347.678.3261

Blog:     http://spaces.msn.com/members/pocketxp/

MSN IM: [EMAIL PROTECTED]

email:   [EMAIL PROTECTED]
url:       http://www.ctadvantage.com

 

Reply via email to