A bug?

Posts   
 
    
Posts: 22
Joined: 20-Sep-2006
# Posted on: 12-Oct-2006 17:38:52   

I have a date time field that at one point was accidently an int DB type. This was corrected to smalldatetime, the schema was refereshed and the project was updated.

When I try and set the field I get a "Cannot implicity convert type System.DateTime to int.

I just downloaded the latest version, 2.0.0.0 (10/3/06) refreshed the schema and regenerated, I still get the same casting error.

v2.0.50727 of the runtime libraries.

I'm not sure where the failure is occuring. I checked the Entity class property for this item and compared it to another class with the same DateTime type. They're identical (with the exception of the name of course). One works the other dosen't

Setup is identical in my class, one works the other dosen't, so I'm not sure where the failure is occuring.

The odd thing is if I mouse over the field where I'm trying to set it _vehicle.AquistionDate it says it's type of DateTime.

Any thoughts?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 12-Oct-2006 19:08:02   

please provide

  • stacktrace
  • code snippet.
Frans Bouma | Lead developer LLBLGen Pro
Posts: 22
Joined: 20-Sep-2006
# Posted on: 12-Oct-2006 20:42:03   

Otis wrote:

please provide

  • stacktrace
  • code snippet.


 /* Private decleration */

      private DateTime _aquisitionDate;

 /* Property */ 

      public DateTime AquisitionDate
        {

            get
            {
                CanReadProperty("AquisitionDate");
                return _aquisitionDate;
            }

            set
            {
                CanWriteProperty("AquisitionDate");
                if (!_aquisitionDate.Equals(value))
                {
                    _aquisitionDate = value;
                    PropertyHasChanged("AquisitionDate");
                }
            }
        }

/* DAL CALL * /

_vehicle.VehicleId = criteria.Id;
            DataCalls.Fetch(_vehicle);

        
            _aquisitionDate = _vehicle.AquistionDate;


the _vehicle.AquisitionDate is identified as type int in this scenario

I would post a stack trace but the code won't compile.

I'm sorry that it's rather vague. I'd be happy to e-mail you the generated classes if it would help, I doubt you want me posting all 1,500 lines here. But just in case this part helps below is the decleration of the VehicleEntity.AquisitionDate field



public virtual System.DateTime AquistionDate
        {
            get
            {
                object valueToReturn = base.GetCurrentFieldValue((int)VehiclesFieldIndex.AquistionDate);
                if(valueToReturn == null)
                {
                    valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.DateTime));
                }
                return (System.DateTime)valueToReturn;
            }
            set { SetNewFieldValue((int)VehiclesFieldIndex.AquistionDate, value); }
        }

As I stated in the last post this setup is identical to one that works.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 12-Oct-2006 21:33:48   

Could you explain which line the error is at? If you already mentioned that, my appologies, I couldn't determine exactly which line the error was on... simple_smile

Also, double check which assemblies you're referencing (generated code). If this is a webapp, check if the assemblies in the bin folder are actually updated, so the website is compiled against the latest generated code assemblies (with the datetime type instead of the int type)

Frans Bouma | Lead developer LLBLGen Pro
Posts: 22
Joined: 20-Sep-2006
# Posted on: 12-Oct-2006 22:33:07   

Well I tried to build a project to show you exactly the problem and to prove I could replicate it, of course, it worked just fine in my test. wink

So I went ahead and created a new project to see if a clean start would resolve the issue. It did, however now I get a different problem.

I'm using a Target-per-Entity

Now in every one of my Sub-Type classes I get two IEntityRelationObjects that are identical. (The Relation object that defines the relationship between the Child and Parent in this case Customer -- Entity)

If I delete them, everything complies, but when I regen they come back.

an example



    /// <summary>Returns a new IEntityRelation object, between CustomerEntity and EntityEntity over the 1:1 relation they have, using the relation between the fields:
        /// Customer.EntityId - Entity.EntityId
        /// </summary>
        public override IEntityRelation EntityEntityUsingEntityId
        {
            get
            {
                IEntityRelation relation = base.EntityEntityUsingEntityId;
                relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("CustomerEntity", true);
                return relation;
            }
        }
    
        /// <summary>Returns a new IEntityRelation object, between CustomerEntity and EntityEntity over the 1:1 relation they have, using the relation between the fields:
        /// Customer.EntityId - Entity.EntityId
        /// </summary>
        public override IEntityRelation EntityEntityUsingEntityId
        {
            get
            {
                IEntityRelation relation = base.EntityEntityUsingEntityId;
                relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("CustomerEntity", true);
                return relation;
            }
        }


Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 13-Oct-2006 09:24:10   
Posts: 22
Joined: 20-Sep-2006
# Posted on: 13-Oct-2006 14:43:04   

Walaa wrote:

Please check the following thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6085

That dosen't really fit my scenario.

Here is a simple data structure

Table Entity

AddressID
EntityID (PK int)
EntityTypeID
IsActive .....

Table Customer Capacity CustomerNo EntityID (PK, FK, int) Name .....

So there is a 1:1 relationship between customer and Entity, and this problem didn't manifest until after I created a new project and recreated the Target-Per-Entity Types with the 10/3/06 version of the software (is it different than the inital 2.0.0.0 release ?)

Anyway it's certainly not impossible that I'm doing something wrong, I'm just trying to figure out what it is, and BTW I checked in the LLBL Designer, and I do see the two relationships on the child type.

Posts: 22
Joined: 20-Sep-2006
# Posted on: 13-Oct-2006 14:50:28   

Ignore that. I just found the problem. Seems I accidently created a relationship from table Entity -> Entity so it was cascading down to all the sub types.

flushed

Sorry, and thanks.