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

ganerate mismatch datatypes !!

3 Answers 55 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ali Kolahdoozan
Top achievements
Rank 2
Ali Kolahdoozan asked on 08 Jan 2011, 03:19 PM
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

3 Answers, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 12 Jan 2011, 04:16 PM
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.
0
Ali Kolahdoozan
Top achievements
Rank 2
answered on 12 Jan 2011, 04:20 PM
Hi

Yes problem on nullable propertys and fields

0
Petko_I
Telerik team
answered on 14 Jan 2011, 07:17 PM
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.
Tags
Databases and Data Types
Asked by
Ali Kolahdoozan
Top achievements
Rank 2
Answers by
Petko_I
Telerik team
Ali Kolahdoozan
Top achievements
Rank 2
Share this question
or