Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > BOOK: Professional LINQ
| Search | Today's Posts | Mark Forums Read
BOOK: Professional LINQ
This is the forum to discuss the Wrox book Professional LINQ by Scott Klein; ISBN: 9780470041819
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional LINQ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 17th, 2009, 04:42 PM
Registered User
 
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Linq to Sql - Retrieving the value of an identity column BEFORE inserting new row

Hello, I'm wondering if there is a way to retrieve the identity value from an identity column before saving a new register.
When I run this query: "SELECT IDENT_CURRENT ('alpa_Animais') AS AnimalID" directly, using the SQL Server Management Studio I get this value.
Does anyone know if there is a way to get this from a method inside a web app using Linq?
Thank you
Josi
  #2 (permalink)  
Old July 17th, 2009, 04:56 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Josi,

If you want to use LINQ to execute that query, I would put it in a stored procedure and execute that proc via LINQ. Should be very easy to do. There are examples of executing procs in the book.

I hope this helps. Let me know if you need any other info.

Scott
__________________
========================
Scott Klein
Author of:
Professional SQL Server 2005 XML
Professional WCF Programming: .NET Development with the Windows Communication Foundation
Professional LINQ
========================
  #3 (permalink)  
Old March 11th, 2011, 04:42 PM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default how do i retrieve primary key value after inserting new column using linq

Hello,
am asking...
is there any way I can retrieve the identity value, of a column after inserting a new database record using linq
i could i achieve this like this using stored procedure:

//insert statement
return @@identity.
how do I achieve thesame with linq

thanks


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq to Sql - Retrieving the value of an identity column BEFORE inserting new row jmartarelli LINQ 2 August 4th, 2010 12:59 PM
Linq to Sql - Retrieving the value of an identity column BEFORE inserting register jmartarelli BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 0 July 17th, 2009 04:33 PM
Inserting & Retrieving Images on Sql Server adamusufi SQL Server 2000 6 June 26th, 2005 03:32 PM
Inserting Images and retrieving from SQL SERVER adamusufi VB.NET 2002/2003 Basics 0 June 24th, 2005 04:13 AM
Inserting a Value into an SQL Identity Field in VB vbmazza VB Databases Basics 1 April 27th, 2005 02:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.