This project is read-only.

Exception when execute context.commit()

Mar 7, 2008 at 9:40 AM

I tried the QuickStart example in the Inside NPersist document. I've done every step in the document. When I trie to create an new
Author or Book and the context.commit() method is called I get a FormatException which say:
Failed to convert parameter value from a String to a Int32

I've even tried the complete code example from the website, but also get this exception when the method is called.
I use Visual Studio 2005 with .NET 2.0 Framework and a SQL Server 2000 database.

I'm hoping someone can help me fix this problem.
Thanks in advance

Mar 10, 2008 at 10:00 PM
Sounds like you are mapping a string to an int.
eg. that some property in your DM classes is of type string and that the column in the database is of type integer.
It should be possible to check the innerException of the exception that you are getting for more details.
Mar 15, 2008 at 1:39 PM
Hi Jarno,

I will take a look at this, I'll get back to you asap.

Mar 15, 2008 at 1:44 PM
(Also, for future reference: )

While Roger's advice is quite correct in general ("Sounds like you are mapping a string to an int."), at this particular point in time it could well be some bug in the recently introduced new way for npersist to handle some of its temporary identities (just that exception happens then when an Integer prop has a temp value which is a Guid.ToString() that is held internally and NPersist by mistake passes it to the function for inserting it into the private (int) field that the (int) prop is mapping, again, will check this out to see if it is a bug in NP.

Actually, I should probably add a special exception message for this scenario which suggests this might be the case :-P Something along the lines of "It is quite possible that you have mapped everything right here and that this is a temporary identity bug inside NP" :-)