I have the following Stored procedure

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

Which is adding records to the following table

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

I have defined the following EmailAuthorization.hbm.xml file

<?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>


and the following class to store entities


namespace GoogleEmailClient.BusinessObjects
{
    /// <summary>
    /// Stores the details of the authorization 
    /// allowing access to a users email
    /// </summary>
    public class EmailAuthorization
    {
        /// <summary>
        /// Unique Id
        /// </summary>
        public Guid ID { get; set; }
 
        /// <summary>
        /// Email Address
        /// </summary>
        public String Email { get; set; }
 
        /// <summary>
        /// Access Token
        /// </summary>
        public String AccessToken { get; set; }
 
        /// <summary>
        /// Date the Access Token was issued
        /// </summary>
        public DateTime Issued { get; set; }
 
        /// <summary>
        /// Refresh Token - used to renew Access Token whenb
        /// it runs out
        /// </summary>
        public String RefreshToken { get; set; }
    }
}


Finally the hibernate.cfg.xml file contains the following;


<?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>


Stack Trace of the error is as follows


[KeyNotFoundException: The given key was not present in the dictionary.]
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +9629069
   
NHibernate.Param.NamedParameterSpecification.SetEffectiveType(QueryParameters 
queryParameters) +60
   
NHibernate.Param.ParametersBackTrackExtensions.ResetEffectiveExpectedType(IEnumerable`1
 parameterSpecs, QueryParameters queryParameters) +126
   
NHibernate.Engine.Query.NativeSQLQueryPlan.PerformExecuteUpdate(QueryParameters 
queryParameters, ISessionImplementor session) +341

[GenericADOException: 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]]
   
NHibernate.Engine.Query.NativeSQLQueryPlan.PerformExecuteUpdate(QueryParameters 
queryParameters, ISessionImplementor session) +977
   NHibernate.Impl.SessionImpl.ExecuteNativeUpdate(NativeSQLQuerySpecification 
nativeQuerySpecification, QueryParameters queryParameters) +253
   NHibernate.Impl.SqlQueryImpl.ExecuteUpdate() +141
   GoogleEmailClient.GoogleAuthorization.ProcessRequest(HttpContext context) in 
c:\users\paul\documents\visual studio 
2010\Projects\GoogleEmailClient\GoogleEmailClient\GoogleAuthorization.ashx.cs:61
   
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
 +100
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 
completedSynchronously) +75



I cannot see what to do to fix the error



Reply via email to