Putz!!
it was my problem!!!
thaks so much!!

i had made a mistake!!

thanks a lot


On Wednesday, February 15, 2017 at 2:34:57 PM UTC-3, Quicoli wrote:
>
> Hi, your problem is here I believe:
>
> *resultado = (string)session.Save(entidade)*;
>
> what do you want return?
>
> 2017-02-15 15:07 GMT-02:00 Antonio Kuroki <[email protected] <javascript:>
> >:
>
>> I am tring to do a sample exemple using Fluent NHibernate but i am having 
>> some dificults
>>
>> this is my code:
>>
>> * public class Categoria*
>> *    {*
>> *        public virtual int Id { get; protected set; }*
>> *        public virtual string Descricao { get; set; }*
>> *    }*
>>
>> *public class CategoriaMap : ClassMap<Categoria>*
>> *    {*
>> *        public CategoriaMap()*
>> *        {*
>> *            //Table("Categoria");*
>> *            Id(x => x.Id); 
>> //.Column("Id").CustomType("System.Int32").GeneratedBy.Identity();*
>> *            Map(x => x.Descricao);*
>> *        }  *
>> *    }*
>>
>>
>> here is the insert method on my DAO:
>>
>> * public string incluir(Categoria entidade)*
>> *            {*
>> *                String resultado = null;*
>> *                ISession session = null;*
>> *                ITransaction transaction = null;*
>>
>> *                try*
>> *                {*
>> *                    session = HibernateHelper.OpenSession();*
>> *                    transaction = session.BeginTransaction();*
>>
>> *                    resultado = (string)session.Save(entidade);*
>> *                    transaction.Commit();*
>> *                }*
>> *                catch (Exception e)*
>> *                {*
>> *                    resultado = e.Message;*
>> *                    transaction.Rollback();*
>> *                }*
>> *                finally*
>> *                {*
>> *                    if (transaction.IsActive && 
>> !transaction.WasCommitted)*
>> *                    {*
>> *                        transaction.Commit();*
>> *                    }*
>> *                }*
>>
>>
>> *                return resultado;*
>> *            }*
>>
>> my table script:
>>
>> *CREATE TABLE [dbo].[Categoria](*
>> * [Id] [int] IDENTITY(1,1) NOT NULL,*
>> * [Descricao] [varchar](50) NULL,*
>> * CONSTRAINT [PK_Categoria] PRIMARY KEY CLUSTERED *
>> *(*
>> * [Id] ASC*
>> *)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = 
>> OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]*
>> *) ON [PRIMARY]*
>>
>>
>> when i run my project, i receive this erro:
>>
>> *NHibernate: INSERT INTO [Categoria] (Descricao) *
>> *VALUES (@p0); select SCOPE_IDENTITY();*
>> *@p0 = 'Categoria A' [Type: String (4000)]*
>> *Unable to cast object of type 'System.Int32' to type 'System.String'.*
>>
>>
>> Does anybody knows how to resolve it?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/nhusers.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to