Problem mapping SQLite database

5 posts, 1 answers
  1. SteveL
    SteveL avatar
    68 posts
    Member since:
    Apr 2009

    Posted 14 Jul 2010 Link to this post

    I was very pleased to see SQLite databases now supported, as I've been waiting for this for some time now, so I am trying to change my project to use OpenAccess ORM instead of Entity Framework.

    After I have added a Domain Model, I get the error: The specified ado type of the column timestamp does not exist.

    'Timestamp' is my primary key, and is of type DateTime. So I set the type to DateTime using the Resolve Validation Errors dialogue, and build my project.

    I then get the error:

    Error   56   Field: 'System.Object CumulusService.StandardDatum::timestamp': The type of the single field identity field must be System.Byte, System.Int16, System.Int32, System.Int64, System.Guid, System.Char or System.String.
    Parameter name: fieldType   C:\Users\steve\Documents\Visual Studio 2010\Projects\CumulusService\CumulusService\obj\x86\Debug\CumulusService.exe   CumulusService

    What does this mean, please? Please don't say that OpenAccess ORM doesn't support a DateTime primary key? I don't have this problem with EF.

    Steve
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 15 Jul 2010 Link to this post

    Hello SteveL,

    I am afraid that this is not supported right out of the box but there is a workaround that would work fine. Let me explain a bit - each persistent class has an instance implementing the IObjectID interface which is used by the runtime to manage the persistent object's identity. When the class has only one identity field, one of the predefined classes that implement the IObjectID interface is used. At the moment such classes are available only for the types that are listed in the message of the error you got. In case of multiple identity fields, the object id class is automatically generated as a nested class in the persistent class, thus allowing you to have any combination of identity field types. So in your case, in order to have an object id class with one field of type DateTime, you can use a multiple field identity but have only one field - your DateTime primary key. This way the corresponding nested class will be generated in the persistent class.
    To achieve that, please open the .rlinq file with an xml editor and replace this node:
    <orm:identity>
        <orm:single-field field-name="timestamp" />
    </orm:identity>
    with the one below:
    <orm:identity>
        <orm:multiple-field class-name="YourNamespace.YourClassName+ID">
            <orm:single-field field-name="timestamp" />
        </orm:multiple-field>
    </orm:identity>
    Where YourNamespace is the namespace of the persistent class and YourClassName is its name.
    Reopen the diagram in the designer and click Save to execute the code-generation process. Then you should be able to build the project and work with this persistent class as expected.

    We are aware that this workaround is not very elegant and we will put effort to improve this area of the product for the next Q. Hope that helps.

    Greetings,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. SteveL
    SteveL avatar
    68 posts
    Member since:
    Apr 2009

    Posted 15 Jul 2010 Link to this post

    Thank you, Alexander, that works just fine.

    Steve
  5. David Pusch
    David Pusch avatar
    1 posts
    Member since:
    Feb 2010

    Posted 21 Sep 2010 Link to this post

    Would this be an issue that will be addressed in the Q3 2010 release?
  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 23 Sep 2010 Link to this post

    Hello David Pusch,

    Our plans are to make bigger changes in this area, probably even removing the ID classes but this will most likely not make it for Q3. As there is a relatively easy workaround for this issue, it is not considered high priority. We are sorry for the inconvenience.

    Best wishes,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner