I get the following error when executing a stored procedure

*could not execute native bulk manipulation query:exec 
EmailAuthorizationsInsert @Id=:Id @Email=:Email @AccessToken=:AccessToken 
@Expiration=:Expiration @Issued=:Issued @RefreshToken=:RefreshToken[SQL: 
SQL not available]*

Inner Exception is

*The given key was not present in the dictionary*

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8" ?><hibernate-configuration 
xmlns="urn:nhibernate-configuration-2.2">  <session-factory>    <property 
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>    
<property 
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>    
<property name="connection.connection_string">Data Source=pc-acer\dev;Initial 
Catalog=Email;Integrated Security=True</property>    <property 
name="show_sql">true</property>  </session-factory></hibernate-configuration>


EmailAuthorization.hbm.xml


<?xml version="1.0" encoding="utf-8" ?><hibernate-mapping 
xmlns="urn:nhibernate-mapping-2.2" assembly="GoogleEmailClient" 
namespace="GoogleEmailClient.BusinessObjects">  <class 
name="EmailAuthorization" table="EmailAuthorizations">    <id name="Id">      
<generator class="guid" />    </id>    <property name="Email" />    <property 
name="AccessToken" />    <property name="Expiration" />    <property 
name="Issued" />    <property name="RefreshToken" />  
</class></hibernate-mapping>


Code to execute Stored Procedure


            ISession session = NHibernateHelper.GetCurrentSession();
            IQuery query = session.CreateSQLQuery("exec 
EmailAuthorizationsInsert @Id=:Id @Email=:Email @AccessToken=:AccessToken 
@Expiration=:Expiration @Issued=:Issued @RefreshToken=:RefreshToken");
 
            query.SetGuid("Id", Guid.NewGuid());
            query.SetString("Email", user);
            query.SetString("AccessToken", grantedAccess.AccessToken);
            
query.SetDateTime("Expiration",Convert.ToDateTime(grantedAccess.AccessTokenExpirationUtc));
            query.SetDateTime("Issued", 
Convert.ToDateTime(grantedAccess.AccessTokenIssueDateUtc));
 
            query.ExecuteUpdate();


Stored Procedure being executed

CREATE PROCEDURE [dbo].[EmailAuthorizationsInsert]
@ID UniqueIdentifier,
@Email VarChar(MAX),
@AccessToken VarChar(MAX),
@Expiration DateTime,
@Issued DateTime,
@RefreshToken VarChar(MAX)
AS
BEGIN
SET NOCOUNT ON;

INSERT INTO EmailAuthorizations
                (Email
                , AccessToken
                , Expiration
                , Issued
                , RefreshToken)
VALUES     (@Email
, @AccessToken
, @Expiration
, @Issued
, @RefreshToken)
END


And for completeness the table definition

USE [Email]
GO

/****** Object:  Table [dbo].[EmailAuthorizations]    Script Date: 
11/25/2012 22:28:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[EmailAuthorizations](
[ID] [uniqueidentifier] NOT NULL,
[Email] [varchar](max) NOT NULL,
[AccessToken] [varchar](max) NOT NULL,
[Expiration] [datetime] NOT NULL,
[Issued] [datetime] NOT NULL,
[RefreshToken] [varchar](max) NOT NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

Any ideas 

Thanks in advance

Reply via email to