Number(1) to Boolean conversion

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
ChrisWalker
Posts: 10
Joined: Mon 01 Mar 2010 20:17
Contact:

Number(1) to Boolean conversion

Post by ChrisWalker » Wed 31 Mar 2010 16:30

I have an oracle table that has a column 'ORDINAL' defined as a Number(1). In my code I need to modify the value and save it back to the database. I don't control the database. It is a legacy database being generated by a different entity.

I opened up the Entity Developer for dotConnect modeling tool and added the USER_PASSWORD_HISTORY table. The column ORDINAL gets added as a type of Boolean. If I try to edit the type to 'Int32' (or byte or anything else) I get the error below.

I was thinking about going into the ...Designer.cs file and manually changing bool to int but I have been regenerating the model as I add and modify tables and don't want to have to do that every time I modify the model. Any help?


1 Member Mapping specified is not valid. The type 'Edm.Int32[Nullable=False,DefaultValue=]' of member 'Ordinal' in type 'DMS.Entities.Pearl.User.UserPasswordHistory' is not compatible with 'Devart.Data.Oracle.bool[Nullable=False,DefaultValue=]' of member 'ORDINAL' in type 'DMS.Entities.Pearl.User.Store.USER_PASSWORD_HISTORY'. UserPasswordHistory

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 01 Apr 2010 07:55

The problem is associated with the fact that the store type of the column is set to bool while you are setting the conceptual type to Int32. Change the store type in the Store part of the model to the corresponding one (int, for example).

ChrisWalker
Posts: 10
Joined: Mon 01 Mar 2010 20:17
Contact:

Post by ChrisWalker » Mon 05 Apr 2010 14:54

If I understand what you are saying it is to change the bolded bool to int in the part of the model shown below. However, if I do that, then I will need to do it EVERYTIME I regenerate the model correct?

///
/// There are no comments for Property Ordinal in the schema.
///
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public bool Ordinal
{
get
{
bool value = this._Ordinal;
OnGetOrdinal(ref value);
return value;
}
set
{
this.OnOrdinalChanging(ref value);
this.ReportPropertyChanging("Ordinal");
this._Ordinal = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
this.ReportPropertyChanged("Ordinal");
this.OnOrdinalChanged();
}
}
private bool _Ordinal;
partial void OnGetOrdinal(ref bool value);
partial void OnOrdinalChanging(ref bool value);
partial void OnOrdinalChanged();

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 06 Apr 2010 14:25

Not quite, there is no need to make any changes in the generated code.
You should open your .edmx model (if you are using Microsoft designer) using XML Editor you like and change the type of the property to bool in both SSDL and CSDL part of the model.
In case you are using Entity Developer it will be enough only to set the corresponding properties in design time (both in the Model and Store parts).
The code will be regenerated correctly, but any update made to the model by using Update from database wizard will overwrite the manual changes made to the model - this is a limitation of Microsoft designer. I recommend you to use Entity Developer.

ChrisWalker
Posts: 10
Joined: Mon 01 Mar 2010 20:17
Contact:

Post by ChrisWalker » Tue 06 Apr 2010 17:50

Excellent. I was able to modify both the store and conceptual entries in the .edmx file and then bring up the designer again and regenerate the code correctly. Thanks for the help

Post Reply