ganerate mismatch datatypes !!

4 posts, 0 answers
  1. Ali Kolahdoozan
    Ali Kolahdoozan avatar
    7 posts
    Member since:
    Feb 2010

    Posted 08 Jan 2011 Link to this post

    Hi


    When i generate a linqtosql class from sqlmetal or vs.net 2010 for some fields may be generate System.Nullable but by telerik orm generate without system.nullable , its a problem ? how can i have a trust propertys ?


    Regards
    Ali
  2. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 12 Jan 2011 Link to this post

    Hello Ali Kolahdoozan,

    Do you refer to the reverse mapping capabilities of OpenAccess, i.e. have you generated a domain model from the database? When using the Visual Designer and you add MetaProperties to MetaClasses by right-clicking the class and selecting Add -> Add Property the MetaProperties by default their Nullable attribute is set to false. The same behavior is observed with LinqToSql. That is why we suspect you have used the reverse mapping capabilities. In general, when you generate a model from the database OpenAccess generates Nullable properties for all columns in the database that can be assigned a NULL value. The columns that cannot be null naturally are mapped to non-nullable properties. There is an exception to this rule for nullability and it is when the mapped property type is string. Since string fields can always be assigned a null value the Nullable attribute does not affect them and by default it is set to false. Can you confirm that this is the case and can you otherwise give us an example where the mentioned condition does not hold? 

    Do not hesitate to contact us, should you have further questions.

    Best wishes,
    Petko_I
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Ali Kolahdoozan
    Ali Kolahdoozan avatar
    7 posts
    Member since:
    Feb 2010

    Posted 12 Jan 2011 Link to this post

    Hi

    Yes problem on nullable propertys and fields

  5. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 14 Jan 2011 Link to this post

    Hello Ali Kolahdoozan,

    After having a closer look at your first post we noticed that you mention System.Nullable. OpenAccess generates the nullable properties in the form int?, double?, etc. In fact, System.Nullable<int> and int? are interchangeable and they refer to one and the same struct. Have a look at the following article. Is this where your concerns come from? As explained in the article there are two alternatives to declaring nullable fields and LinqToSql and OpenAccess use different ones. Or are there any properties for which you have noticed a mismatch between the database nullability and the property type nullability? If there are any discrepancies you have noticed, we would kindly ask you to give us an example so that we can further investigate. A sample table definition would be enough. 

    You should not worry about the mapped String properties which have their Nullable attribute set to false. The Nullable attribute can be viewed by selecting a property in the entity diagram and pressing F4. The Nullable attribute is interpreted in the code generation process so that we generate properties such as nullable ints (int?). As we mentioned, the String type is one that accepts null values and you cannot declare a Nullable<string> type as this results in a compilation error.  In LinqToSql the Nullable attribute for the mapped properties reflects the nullability in the database. With OpenAccess you can check the nullability of the mapped columns in the Model Schema Explorer when you select a concrete column and browse its properties by pressing F4. The nullable columns have their IsNullable attribute set to true.  Furthermore, the Table Editor provides additional control over the null values for a column. With the help of this editor you can change and view different options for the mapped tables.

    Should you have any other questions, feel free to contact us.

    Greetings,
    Petko_I
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top