Custom Types in domain model

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

    Posted 10 Oct 2011 Link to this post


    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,
  2. Ady
    Ady avatar
    589 posts

    Posted 13 Oct 2011 Link to this post

    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,
    the Telerik team

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

Back to Top