Type conversion for complex CLR type (Money)

4 posts, 0 answers
  1. Norbert
    Norbert avatar
    35 posts
    Member since:
    Dec 2009

    Posted 21 Nov 2011 Link to this post

    Hello guys,

    I would like to know how I can handle the following conversion problem:
    I have a Money type within my base class and I want to store them into database. The problem is that the value is not the only thing I wanna store - currency and other few thinks should be stored also. I've read the blog about type conversion but it doesn't describe how to handle the case from one complex type to several columns in database.

    Maybe you can help me,
    thank you very much
    Norbert
  2. Ady
    Admin
    Ady avatar
    588 posts

    Posted 24 Nov 2011 Link to this post

    Hi Norbert,

     Is this 'Money' type a custom type implemented by you or are you referring to 'System.Data.SqLTypes.SqlMoney' ? (assuming you are working against Sql Server). Is Money marked as a Persistent type? Can you provide more details of what you want to achieve, maybe with an example.

    Looking forward to assisting you.

    Regards,
    Ady
    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

  3. DevCraft banner
  4. Norbert
    Norbert avatar
    35 posts
    Member since:
    Dec 2009

    Posted 24 Nov 2011 Link to this post

    Hello,

    thank you for answering.

    I have a custom type named Money with for example 2 properties like Value and Currency. Within my base class lib I've defined a type like Order with properties of name, quantity and price --> the price property should be of type Money.
    Is there a way to handle that within OA? Is there a best case?
    The only thing I can imagine is to build the money props through a 1:1 relation separated into 2 tables...but there must be a better approach.
    In short - I want to store my whole order type into 1 table with, name, quantity, value, currency...

    Thanks in advance
    Norbert
  5. Ady
    Admin
    Ady avatar
    588 posts

    Posted 29 Nov 2011 Link to this post

    Hi Norbert,

    Storing the 'Money' type in the same table as 'Orders' is possible only if the 'Money' type is a persistent struct and struct support is only available via the 'Classic' product. You can find more information under the 'User-defined value types' section on this page.
    In case you need to use structs with the domain model approach the mapping for the persistent struct and fields of this type will need to be set explicity in the metadata (by modifying the MetadataContainer) or you can alternatively just store it as another persistent type with its own table.

    Do get back in case you need further assistance.

    All the best,
    Ady
    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Back to Top