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

Custom Types in domain model

1 Answer 73 Views
General Discussions
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 10 Oct 2011, 02:20 PM
Hello,

I want to know if it is possible to use custom types within my domain model? I've the caase that I want to use a Money type instead of double or decimal in my app but in the database of courde it should be stotred as decimal values.

How can I reach that? When I change the datatype in the model (Money is defined already) I get the message:
Unbehandelte Ausnahme: Telerik.OpenAccess.Exceptions.MetadataException: The meta
data for field '_durchschnittspreis' of class 'ES.Energizer.Core.Deal' cannot be
 initialized: Type converter initialization failed. The converter with name 'Dou
bleConverter' does not convert from CLR type 'System.Money' to SQL type 'float'.

Could you help me please,
Norbert

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 13 Oct 2011, 02:43 PM
Hi Norbert,

 Do you intend to use the System.Data.SqlTypes.SqlMoney data type or is this your own implementation? In case you want to use the SqlMoney CLR type that maps to a 'money'  SQL column,which is the common use case, you can specify SqlMoney as the type for the property in the designer and specify a type converter for each field that is mapped to a 'money' column. I have attached a sample that demonstrates this.
In case you want to map a decimal column to a Money type you would need to implement the AdoTypeConverter interface to convert decimal values to your own Money implementation.

Do let me know if you need more information.

Kind regards,
Ady
the Telerik team

Check out the latest stable build of Telerik OpenAccess ORM. Download it and benefit from our new Project Templates.

Tags
General Discussions
Asked by
Norbert
Top achievements
Rank 2
Answers by
Ady
Telerik team
Share this question
or