Ok, I have determined that this is in the DBML template, and possibly an issue with the ParameterSchema object.
I am using the below table, and have tried several varations of the insertEmployee
- Return SCOPE_IDENTITY()
- SET a OUPUT parameter with SCOPE_IDENTITY
- Create a local parameter, set it to SCOPE_IDENTITY and return.
All of these yield the below results.
Any assistance would be greatly appreciated.
Thanks.
Larry
USE [test]
GO
/****** Object: Table [dbo].[Emp] Script Date: 05/19/2008 10:49:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Emp](
[EmpID] [int] NOT NULL,
[EmpName] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MgrID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[EmpID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Emp] WITH CHECK ADD FOREIGN KEY([MgrID])
REFERENCES [dbo].[Emp] ([EmpID])
Create PROCEDURE [dbo].[insertEmployee]
-- Add the parameters for the stored procedure here
@empName varchar(30) = null,
@mgrId int = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into Emp ( EmpName, MgrId ) values (@empName,@mgrId)
END
Return SCOPE_IDENTITY
<?xml version="1.0" encoding="utf-16"?>
<Database Name="test" EntityNamespace="CBDSS.Data" ContextNamespace="CBDSS.Data" Class="TestDataContext" EntityBase="EntityBase" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Connection Mode="AppSettings" ConnectionString="Data Source=.\sqlexpress;Initial Catalog=test;Integrated Security=True" SettingsObjectName="Properties.Settings" SettingsPropertyName="TestConnectionString" Provider="System.Data.SqlClient" />
<Table Name="dbo.Emp" Member="Emp">
<Type Name="Emp">
<Column Name="EmpID" Member="EmpID" Storage="_empID" Type="System.Int32" DbType="int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="EmpName" Member="EmpName" Storage="_empName" Type="System.String" DbType="varchar(30)" CanBeNull="true" />
<Column Name="MgrID" Member="MgrID" Storage="_mgrID" Type="System.Int32" DbType="int" CanBeNull="true" />
<Association Name="FK__Emp__MgrID__7D78A4E7" Member="MgrEmp" Storage="_mgrEmp" ThisKey="MgrID" OtherKey="EmpID" Type="Emp" IsForeignKey="true" />
<Association Name="FK__Emp__MgrID__7D78A4E7" Member="MgrEmpList" Storage="_mgrEmpList" ThisKey="EmpID" OtherKey="MgrID" Type="Emp" />
</Type>
</Table>
<Function Name="dbo.insertEmployee" Method="InsertEmployee">
<Parameter Name="@empName" Parameter="empName" Type="System.String" DbType="varchar(30)" />
<Parameter Name="@mgrId" Parameter="mgrId" Type="System.Int32" DbType="int" />
<ElementType Id="InsertEmployee1" Name="InsertEmployeeResult">
<Column Name="" Member="" Type="System.Decimal" CanBeNull="true" />
</ElementType>
</Function>
</Database>