Latest Version Generated Code Bug?
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1478
Printed Date: 21-Sep-2025 at 9:28pm
Topic: Latest Version Generated Code Bug?
Posted By: skingaby
Subject: Latest Version Generated Code Bug?
Date Posted: 17-Sep-2009 at 11:20am
It seems the generated code has an invalid setting for the DefaultValue for boolean properties in C#:
[Bindable(true, BindingDirection.TwoWay)]
[Editable(true)]
[Display(Name="Promoted", AutoGenerateField=true)]
[IbVal.ValidateProperty]
[IbVal.RequiredValueVerifier()]
[IbCore.DBDataType(typeof(Boolean))]
[DefaultValue(False)]
[MsSer.DataMember]
public Boolean Promoted {
get { return PromotedEntityProperty.GetValue(this); }
[global::System.Diagnostics.DebuggerNonUserCode]
set { PromotedEntityProperty.SetValue(this, value); }
}
Notice the upper case False. A lower case false works fine. A simple find and replace has fixed it for me. Am I doing something wrong though? Is my mapping file wrong somewhere? Thanks, Simon.
|
Replies:
Posted By: skingaby
Date Posted: 17-Sep-2009 at 11:34am
Also, I am getting this error when I try to run the app:
Assembly Initialization method GcsAg.DomainModel.Test.AssemblyInitialization.AssemblyInit threw exception. IdeaBlade.EntityModel.EntityServerException: IdeaBlade.EntityModel.EntityServerException: Error loading entity relations ---> IdeaBlade.Core.IdeaBladeException: Error loading entity relations ---> System.InvalidCastException: Invalid cast from 'System.Boolean' to 'System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.. Aborting test execution.
System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
System.Boolean.System.IConvertible.ToType(Type type, IFormatProvider provider)
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
IdeaBlade.EntityModel.DataEntityProperty.UpdateDefaultValue()
IdeaBlade.EntityModel.DataEntityProperty..ctor(Type entityType, String propertyName, Type dataType, Boolean isNullable, Boolean isPartOfKey, ConcurrencyStrategy concurrencyStrategy, Boolean isAutoIncrementing, VerificationSetterOptions verificationSetterOptions, Boolean isNativeProperty)
ctor(String propertyName, Boolean isNullable, Boolean isPartOfKey, ConcurrencyStrategy concurrencyStrategy, Boolean isAutoIncrementing, VerificationSetterOptions verificationSetterOptions, Boolean isNativeProperty)
ctor(String propertyName, Boolean isNullable, Boolean isPartOfKey, ConcurrencyStrategy concurrencyStrategy, Boolean isAutoIncrementing, VerificationSetterOptions verificationSetterOptions)
GcsAg.DomainModel.Contact..cctor() in C:\_dev\GcsAg090720\GcsAg.DomainModel\GcsAg.DomainModel.ServerModel.Designer.cs: line 16264
IdeaBlade.EntityModel.EntityServerProxy.CheckConnection(Exception e)
IdeaBlade.EntityModel.EntityServerProxy.Fetch(SessionBundle bundle, IEntityQuerySurrogate query)
IdeaBlade.EntityModel.EntityManager.ExecuteServerQuery(IEntityQuerySurrogate pEntityQuery)
IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)
IdeaBlade.EntityModel.EntityManager.ExecuteServerQuery(IEntityQuerySurrogate pEntityQuery)
IdeaBlade.EntityModel.EntityManager.ExecuteFetch(IEntityFinder finder)
IdeaBlade.EntityModel.EntityQueryFinder.Execute()
IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean isAsync)
IdeaBlade.EntityModel.EntityManager.ExecuteQuery(IEntityQuery query)
GcsAg.DomainModel.DomainModelEntityManager.InitializeCache() in C:\_dev\GcsAg090720\GcsAg.DomainModel\DomainModelEntityManager.cs: line 235
GcsAg.DomainModel.DomainModelEntityManager.InitializeEntityManagerOnServer() in C:\_dev\GcsAg090720\GcsAg.DomainModel\DomainModelEntityManager.cs: line 44
GcsAg.DomainModel.DomainModelEntityManager.InitializeEntityManager() in C:\_dev\GcsAg090720\GcsAg.DomainModel\DomainModelEntityManager.cs: line 30
GcsAg.DomainModel.Test.AssemblyInitialization.AssemblyInit(TestContext context) in C:\_dev\GcsAg090720\GcsAg.DomainModel.Test\AssemblyInitialization.cs: line 17
|
Posted By: kimj
Date Posted: 17-Sep-2009 at 12:10pm
Re the first post - We take whatever is defined in the DefaultValue attribute for the property in the EDMX file, and don't validate its correctness or make it language-specific. So, if you modify the EDMX to use DefaultValue="false" for these properties the code should generate correctly for C#.
Just saw your second post ...
|
Posted By: kimj
Date Posted: 17-Sep-2009 at 12:30pm
Re the exception - that would be a bug. We do attempt conversion of the DefaultValue when we stuff it into the entity, and Convert.ChangeType is throwing because of the Nullable<Boolean>. For now, DefaultValue won't work with nullable types other than string. We'll add this to the defect list. Thanks for reporting it.
|
Posted By: skingaby
Date Posted: 17-Sep-2009 at 12:49pm
As a point of order, the bug with nullable types may well be a bug, but it is also a bug on our end because the fields are boolean but have not been marked as NOT NULL in the database when they should have been.
Thanks kimj, your responses are always quick and helpful.
|
|