This is a migrated thread and some comments may be shown as answers.

Type conversion for complex CLR type (Money)

3 Answers 42 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Norbert
Top achievements
Rank 2
Norbert asked on 21 Nov 2011, 02:21 PM
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

3 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 24 Nov 2011, 02:36 PM
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!

0
Norbert
Top achievements
Rank 2
answered on 24 Nov 2011, 03:10 PM
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
0
Ady
Telerik team
answered on 29 Nov 2011, 03:01 PM
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!

Tags
Development (API, general questions)
Asked by
Norbert
Top achievements
Rank 2
Answers by
Ady
Telerik team
Norbert
Top achievements
Rank 2
Share this question
or