This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I checked the Id and mappings and they are correct. Any idea on the error?
|
|
|
Is Id set to Promary key in the Database? |
|
|
Primary Key I mean |
|
|
We don't really have enough info to be confident, but it could be that you've declared your own Id property which is shadowing the entity base class Id property. If you could provide us with the entity class definition and the CREATE TABLE statement (and the code that causes the error if it's not a straight Find), that would help us to diagnose the problem. Thanks! |
|
|
I fixed the problem by changing the Primary Key data type into "int", before it was "string". By the way, I'm using IdentityColumn. For some scenario, is it possible to use string data type for PK? Thanks! |
|
|
It is possible to use string identities, but you'll run into issues with identity generation if you're creating new entities. (You'll be fine if you're just reading from the table, e.g. mapping a lookup table or reference data.) Most of the provided identity methods generate numeric values or GUIDs. To generate string identities, I think you would need to either: * Use IdentityMethod.IdentityColumn, with a string PK column, and a trigger or some other mechanism to generate string keys in the database (I haven't tested this); or * Override Entity.GeneratedId() to create a string key on demand. You *might* be able to use IdentityMethod.Guid, since Guids are convertible into strings, but we haven't tested this either, and it's not very useful (if you're going to use GUID keys, use a Guid PK) -- the only reason I can think of to try this is if a table contains existing data with arbitrary string keys, but you're happy to restrict new data to GUID keys. |
|
|
Actually the value of my PK before was Alpha. This is the previous schema: CountryId (PK) - "UK" So now I changed to: CountryId (PK) - 1 I only use this schema for reading purposes. Thanks Ivan.
|
|