Fluent API - StringPropertyConfiguration - Unlimited length

8 posts, 1 answers
  1. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 02 Dec 2010 Link to this post

    How do I specify that particular string is supposed to be unlimited using fluent mapping configuration ?
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 03 Dec 2010 Link to this post

    Hi Roland,

     You can do so by specifying the database type this column is mapped to. This can be done by using the HasColumnType method of the Fluent Mapping API. For example if you are using MS SQL Server you will have to input "nvarchar(MAX)" as its type.

    I hope this is helpful, if you have any other questions or face further trouble please let us know.

    Regards,
    Serge
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 03 Dec 2010 Link to this post

    How this will work when I switch to SQLite or oracle or any other db?

  5. Serge
    Admin
    Serge avatar
    375 posts

    Posted 06 Dec 2010 Link to this post

    Hi Roland,

     At the time being there is no straight forward way of specifying this, we will be working on support for default values for the container which is a feature that will solve this issue. However for the moment there is an easy workaround you can use. 

    Given the fact that the fluent mapping is generated during runtime you can easily change the string value you provide to the HasColumnType based on the current backend. 

    We have implemented a similar solution for a customer by defining an attribute that holds the column types for different backends, that one can place over his properties and a set of extensions methods for the Fluent Mapping API that given a backend would read this attribute and set the column type correctly . If you are interested in this solution we will be more than happy to provide it.

    I hope this is helpful.

    Kind regards,
    Serge
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  6. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 06 Dec 2010 Link to this post

    Yes, I would be interested in this solution.

    PS. What I was expecting is the ORM mapper to know how to map the .NET types to DB types. If string is > 8000 for mssql it should use 'text' type for example not varchar(255). etc.

    This is something to think about.
  7. Answer
    Serge
    Admin
    Serge avatar
    375 posts

    Posted 07 Dec 2010 Link to this post

    Hi Roland,

    Please have a look at the project that I have attached. It should give you an idea of how you can accomplish this by customizing the Fluent Mapping trough extension methods. As I have already mentioned this implicit type calculation is not something we are looking forward however you should be able to achieve the same result by yourself. 

    If you have any questions or have trouble with the project make sure to let us know. I am looking forward to resolving any issues you might face.

    Best wishes,
    Serge
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  8. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 07 Dec 2010 Link to this post

    This is what I need, but would be nice if api supported that automatically when I say: use default mappings.
  9. Serge
    Admin
    Serge avatar
    375 posts

    Posted 09 Dec 2010 Link to this post

    Hi Roland,

     We will certainly make sure to take this into account when planning the future improvements of the Fluent Mapping API. 

    I would like again to thank you for your feedback and mention that while we strive to give you a working solution at the moment we are open to suggestions about the API. 

    Best wishes,
    Serge
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top
DevCraft banner