I'm using NHibernate with SQL Server Express Edition and I've been problems with the data type to be defined in the "type" attribute on the "property" tag in the XML file mapping.
Has someone worked with that?
I need to match the appropriate NHibernate type to the following SQL Server Types:
I have been getting "type mismatch" error when the code is trying access the data.
Thanks a lot!
Hi oalexandrino,
Could you please post your detailed mapping schema here so we can better help you? Seems your problem is caused by uniqueidentifier. Anyway, I have read an article and it says you can configure your mapping file like this:
To map to a SQL Server instance, here is what your configuration settings might look like:
<configuration> <configSections><section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" /> </configSections> <nhibernate><add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/><add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/><add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" /><add key="hibernate.connection.connection_string" value="Server=localhost;initial catalog=nhibernate;UserID=someuser;Password=somepwd;Min Pool Size=2"/></nhibernate></configuration>
There are also some other steps you need to follow, see:http://www.theserverside.net/tt/articles/showarticle.tss?id=NHibernate It should help you solve your prolbem.Thanks
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
|||
helloChen!
Firstly thanks by your answer.
So, in order to solve my problem I looked for something around internet to extract automatically this XML according to database schema.
Then I found thisSmartCode
http://www.codeproject.com/useritems/SmartCode-Code_Generation.asp
It is a useful tool because reading the tables in database and creates for each one an NHibernate mapping with all .NET types according with SQL types in the database.
That gave me what problem I was getting!
thanks!
No comments:
Post a Comment